Have a look at the following piece of code
Header File:
class CxUser
{
public:
CxUser(string& guid) {}
};
I have a c++ file that instantiates the class using CxUser(string("xxx-xxx-x-xxxx")). But this statement fails to compile in g++ with error “no matching function for call to CxUser::CxUser(std::string)” whereas it compiles in VC++. Surprisingly, the following piece of code to instantiate the class works.
string guid("xxx-x-xxxx-xxx-xx"); CxUser user(guid);
Any help would be appreciated….
You need:
When you say:
a temporary string object is created from the characterv array. In C++ you cannot bind non-const references to temporaries.