I'm a newbie in CPP and I'm having trouble in understanding how polymorphism works in CPP. I've programmed an example but it won't compile, and I can't understand why.
Oh btw, don't include stuff other then the corresponding .h file in .cpp files. And the reason is because the .h can't see anything in the .cpp, so it has no idea what std::string is.
In your header file you should get into the habit of doing
1 2 3 4
class Phrase {
public:
void phrase( std::string* p ); // Note use of explicit std:: here.
};
In your .cpp file you can choose between using the explicit std:: everywhere,
putting a "using namespace std;" or putting a "using std::string; /* et al */"
at the top of your file.