Feb 25, 2012 at 7:03am UTC
Trying to fix the error below not sure why I am getting it.
I overloaded the >> istream in my CTest class
1 2
CTest ::CTest (string name, int id, string color) //constructor
ifstream & operator >>(ifstream & fin, CTest & rhs) //header
This is in my main
1 2 3 4
ifstream fin = openInput("file.txt" );
... code reading data from fin...
CTest temp("name" ,1,"color" ); //no errors here
fin >> temp; //Error identifier temp is undefined
Yes, I included all the header files
Last edited on Feb 25, 2012 at 9:19pm UTC
Feb 25, 2012 at 8:00am UTC
have you declared fin somewhere?
Last edited on Feb 26, 2012 at 6:46am UTC
Feb 25, 2012 at 9:18pm UTC
Yes fin has been declared, but it is saying "temp is undefined"
Feb 26, 2012 at 6:49am UTC
is there any code of the constructor ?
maybe you have done something wrong in there
Feb 26, 2012 at 10:57am UTC
Do you have defined a default ctor? Can you test your operator >>
with an object created with this?
I think you can post more code if you want to get some help.