Re: Error C2679
Mark wrote:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
[...]
string inFileName;
cin >> inFileName;
[..]
Error 1 error C2679: binary '>>' : no operator found which takes a
right-hand operand of type 'std::string' (or there is no acceptable
conversion)
This program come right out of my textbook, so it should work.
No.
The error acts like the <iostream> wasn???t included.
Nope, it acts as if <string> wasn't included. The operator>> overload for a
std::string is in <string> and not <iostream>. Actually, the standard only
requires that <iostream> declares the classes istream, ostream and the
objects cin, cout, cerr, clog plus their wide counterparts. It doesn't
actually require that it fully defines the class, a simple forward
declaration is enough, so you theoretically <iostream> and <ostream> in
order to write to std::cout. In this case, <ostream> is implicitly included
by <fstream> though.
BTW: two more advanced lessons for you:
1. Read in the filename "C:\Documents and Settings\yourname\foo.barre".
2. Read in a number and then read that many filenames.
Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite
Sator Laser GmbH
Gesch??ftsf??hrer: Thorsten F??cking, Amtsgericht Hamburg HR B62 932