I have this header file, zeeheader.h, and I wrote some classes in it, I’m having problems giving a string as a parameter to one of the functions:
class DeliTest
{
public:
void DeliCheck(Stack*,string);
void ComCheck (unsigned,string);
bool EofCheck (unsigned,string);
};
As I was implementing it in the cpp file, I added #include to it, it seemed to be working, for example: as I was writing the “data.” I got the “length()” appear by the intellisense, so I thought that it was working, but it wasn’t. I got errors like:
syntax error : identifier ‘string’
overloaded member function not found in ‘DeliTest’
this is one of the functions in the cpp file:
bool DeliTest::EofCheck(unsigned i, string data)
{
if (i == data.length()-1)
return 1;
return 0;
}
Am I supposed to be adding something to the header file?
Make sure to
#include <string>, and becausestringsare in thestdnamespace, you should declare yourstringsasstd::stringin the header.As a sidenote, make sure you do NOT declare
using namespace std;in your header files. This would cause any other headers or c/cpp files that include this header to also use the std namespace. This is called polluting the namespace.