GamePiece::GamePiece& operator=(const GamePiece& right)
should be
GamePiece& GamePiece::operator=(const GamePiece& right)
If you return a value, you should return a value.
ostream& operator<<(ostream& os, const GamePiece& p)
{
os << p.pName << endl;
os << p.pType << endl;
return os;
};
And don't end functions with a semicolon.
You can't change a const object.
Sorry I cant say more, but I gotta go.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
#include <fstream>
friend ostream& operator<< (ostream& os, const GamePiece& p);
friend ofstream& operator<< (ofstream& ofs, const GamePiece& p); //overloaded ofstream operator to save board & piece
friend ifstream& operator>> (ifstream& ifs, GamePiece& p); //overloaded ostream operator to input saved board & piece
ostream& operator<< (ostream& os, const GamePiece& p)
{
os << p.pName << endl;
os << p.pType << endl;
return os;
}
ofstream& operator<< (ofstream& ofs, const GamePiece& p) //overloaded ofstream operator to save board & piece
{
ofs << p.pName << endl;
ofs << p.pType << endl;
return ofs;
}
ifstream& operator>> (ifstream& ifs, GamePiece& p) //overloaded ostream operator to input saved board & piece
{
ifs >> p.pName;
ifs >> p.pType;
return ifs;
}
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Don't append the >> endl. I should have highlighted it last time.
ifstream& operator>> (ifstream& ifs, GamePiece& p) //overloaded ostream operator to input saved board & piece
{
ifs >> p.pName;
ifs >> p.pType;
return ifs;
}
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314