Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
error C2065: 'cout' : undeclared identifier - WTF?
I hope someone can help with this because I'm going out of my mind trying to figure it out.
Before we go any further.. the #include
is about 10 lines above where I get this error.
I doing Ivor's book on VC6++ and am at the bit where he starts writing yet another rambling bit of code making a derived class from a simple CBox class, called CandyBox.
Well I decided rather than do a 'type after me' I would use the Wizard to create my own derived class and all is working fine. UNTIL I put in a simple function ShowCandy which uses cout.(I've still the copy constructor and assignment overload to go btew I haven't forgotten)
Firstly here is "CandyBox.h":#include
class CCandyBox : public CBox
void ShowCandy() const;
Then we have "CandyBox.cpp"#include
void CCandyBox::ShowCandy() const
cout << m_Contents;
Comments left out for space. Basically I've only got constructor destructor there apart from this. It just won;t pick upo the cout no matter where I move the include to, if I only include one include to iostream or if I put includes in everywhere... same thing. The weird thing is that, as you can see, it picks up the include for <cstring> ok and sure enough, when I remove the include for cstring I get the same error as I am getting with the cout.
It's as if it can't see #include
Any help appreciated I'm gnawing my own fingers off.