Hi all,
I am learning C++ using a book by Bruce Eckel, Thinking in C++. I have hit a problem when solving an exercise at the end of one of the chapters which left me a bit confused.
I need to create a struct which has three string objects as its members. This is my code for the header file:
#include <string>
struct TestStruct
{
string a, b, c;
};
I also have the implementation .cpp file for it.
I included the header file on the file where I am using it but the compiler comes up with the error "string does not define a type".
I can see what he sort of means, as string is not a native type, but I can not find a way of solving it.
Is there a problem with my struct declaration?
Hi,
I see what you mean, and it probably will work, but I would like to know why using the .cpp file does not work.
The other thing is that on this book the author says that using the "using"directive(I presume that "std::string a, b, c;" is a sort of using directive) in a .h file was not desirable.
Hi Grey Wolf,
thank you for your help, it did work.
As I am just starting, I am trying to get a programming standard, but obviously it does not work for everything.
Best Regards
Luis