I have a project in that I have file real.h and all project it runs rightly.
With the F11 in Code:: Blocks I create real.cpp and put as header #include “real.h”
Immediately it creates to me problem in following prototype which is in header of real.h
Why it makes him this?
template <typename T>
std::string to_string(T value)
std::ostringstream os ;
os << value ;
return os.str() ;
include\real.h|9|error: 'string' in namespace 'std' does not name a type|
Last edited on
You seem to have forgotten to include the string header. It's an easy enough mistake to make.
OK it works, thanks, but why?
only real.cpp i add.
Without real.cpp i have no problem at all.
It is probably because you happened to include sstream and string before you were using real.h in your other .cpp files.
Then when you created real.cpp it tried to include real.h and failed at compiling because sstream and string weren't included.