1.

Solve : C++ String problem?

Answer»

As FAR as i can tell i should be able to access the String class in these files , but for some reason it gives me an error every time , i can use Strings inside Main no problem , but if i try to work with them in another Class i get the error "Type name Expected" Referring to the member declaration. any help would be appreciated

#include
class StrTest
{
public:
StrTest();
private:
string test;
};

#include
#include "strtest.hpp"
StrTest::StrTest()
{
test = " ";
}string.h is a C header, not a C++ header, and doesn't DEFINE a string class but RATHER a GROUP of string manipulation functions.

what you REALLY want is just "string" for example:

#include

which resolves to the C++ string header. when you use "string.h" you are specifically referring to the C (non ++) "cstring" header, and are simply adding a group of char* manipulation functions.
Thanks BC , I fixed my problem ...

i included iostream .. i don't know why that worked exactly , but now i know that the String Class is just manipulators.

maybe i should stick to char arraysyour welcome.

including iostream fixed the problem because iostream includes the C++ string headers as well.

Quote

but now i know that the String Class is just manipulators.

err... no, string.h as you included it is just a group of manipulators; it has no class DEFINITIONS at all. the header that get's used by including defines the string class which supports a number of methods/properties. It certainly doesn't have as many as more object-oriented languages such as java and the .NET framework, though.


Discussion

No Comment Found