Possible Duplicates:
C++, removing #include<vector> or #include<string> in class header
Forward declare an STL container?
I want to forward declare std::string, by the way, can I forward declare a struct?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
std::string is a typedef so you cannot just forward declare it. You could look up the exact declaration, forward declare that and define the typedef yourself, but then you’d also have to forward declare char_traits and allocator. So this
shouldmight work, although it’s not supposed to*:but in the end you’re probably better off including . I’m also unsure whether these declarations are exactly the same on all platforms, not to mention the problems it would cause should the declaration in the string header ever change.
*see comment below