My compiler keeps generating an error message when I try to declare a string member in a class declaration. I've tried including <string> in both the .cpp and the .h files, but that doesn't seem to help. What am I doing wrong?
The error message is:
error C2146: syntax error : missing ';' before identifier 'name'
And it points to the line string name;
The program is supposed to allow the user to play Battleship, btw.
Hmmm, ok, that fixes it. I guess I just figured that having the source code file Ship.cpp include <string> and using namespace std would be sufficient. I thought I had gotten away with that before in other programs but maybe I'm mistaken. Thanks
Hmmm, ok, that fixes it. I guess I just figured that having the source code file Ship.cpp include <string> and using namespace std would be sufficient.
It would have worked if only you had put the #includes in the source file in the right order.