Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using strings in a constructor

Status
Not open for further replies.

Ipito

Programmer
Jun 16, 2005
4
GB

Hi,

I'm using the VC++ 6.0 compiler and am getting numerous error messages when trying to pass a string as a parameter to a constructor. I've tried a small test and I still get the same error:

#include<string>

class MyClass
{
public:
MyClass(const string &fileName); // error here
};

MyClass::MyClass(const string &fileName)
{
// do stuff
}

When I try to compile this, it gives me several errors about the indicated line, including C2629, C2238. However, if I change the string to an int, it compiles fine. I'd be grateful for any advice.

Cheers
 
'string' is in the namespace 'std'. the references to string should read std::string
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top