When i'm trying to declare a function with a string parameter in .h file an error occurs. I haven't forgot to include string.h =) Everything builds fine when i'm using char[], but the i want the argument to be a string.
views:
469answers:
2
+5
A:
string.h
doesn't exist in C++. Did you mean string
(without the .h
)? Additionally, the string
class resides in the std
namespace you need to qualify the type usage:
std::string timeToStr(std::string);
It would be helpful if you had posted the exact error message and a code to reproduce the error.
Konrad Rudolph
2009-08-20 14:34:14
hehehe ... great minds ;)
Goz
2009-08-20 14:41:56
thanks a lot, i mentioned <code>using namespace std;</code> in my cpp file, but forgot about <code>std::</code> the header.
mknight
2009-08-20 14:57:27
`<string.h> does exist in c++, since it is inherited from c ;). However, it has nothing to do with `<string>`
Evan Teran
2009-08-20 15:35:04
@Evan: yes but `<string.h>` exists only for reasons of backwards compatibility, it should not be used. Use the header `<cstring>` instead, it replaces `<string.h>`.
Konrad Rudolph
2009-08-20 16:16:32
+1
A:
try
#include <string>
instead of
#include <string.h>
they are different things - string.h is the CRT, string is the STL.
gbjbaanb
2009-08-20 14:34:57