Hello all,
i use the following functions in a class:
The errormessage is:Code:// .h ... private: string* machineId; ... public: const string* const getId() const {return machineId;} const string* getDebugString(); ... // .cpp ... const string* Machine::getDebugString() { stringstream ss; ss << " <machine> id= " << *machineId << " start state= " << *( getStateFromStateId(startStateId)->getId() ) << "\n"; // *ERROR* for (vector<State*>::const_iterator i = stateVector.begin(); i != stateVector.end(); ++i) { ss << *( (**i).getDebugString() ); } ss << " </machine>\n"; return new string( ss.str() ); } ...
Could someone please tell me what i'm doing wrong?./src/Machine.cpp: In member function 'const std::string* Machine::getDebugString()':
../src/Machine.cpp:23: error: passing 'const State' as 'this' argument of 'const std::string* State::getId()' discards qualifiers
make: *** [src/Machine.o] Error 1
I tried to apply const-correctness to my program. I guarantee the "getId() const" does not mutate anything in my object to the compiler but he still complains.
thank you in advance!