Link to home
Start Free TrialLog in
Avatar of TookH
TookH

asked on

Error 2558 with vector<>

I've defined a class as follows:

class CDriverInfo
{
public:
     GUID guidCopy;
protected:
     LPGUID lpGuid;
     std::string desc;
     std::string name;

public:
     CDriverInfo() { lpGuid = 0; }
     CDriverInfo( LPGUID newguid, std::string newdesc, std::string newname);
     CDriverInfo(CDriverInfo &copy);
     CDriverInfo& operator=(const CDriverInfo &copy);
     ~CDriverInfo();

     void Clear(void);

     void SetGUID(LPGUID newguid);
     void SetDesc(std::string newdesc);
     void SetName(std::string newname);
     void SetInfo( LPGUID newguid, std::string newdesc, std::string newname);

     LPGUID GetLPGUID(void) { return lpGuid; }
     GUID GetGUID(void) { return guidCopy; }
     std::string GetDesc(void) { return desc; }
     std::string GetName(void) { return name; }
};

In my program, I create a vector<CDriverInfo> and call its push_back() function with a CDriverInfo as the argument:

vector<CDriverInfo> gDDDrivers;

CDriverInfo temp;
temp.SetInfo( guid, desc, name );

gDDDrivers.push_back( temp );

When I compile my project in VC6, I get the following error:

Compiling...
Graphics.cpp
...vc98\include\xmemory(34) : error C2558: class 'CDriverInfo' : no copy constructor available
...vc98\include\xmemory(66) : see reference to function template instantiation 'void __cdecl std::_Construct(class CDriverInfo *,const class CDriverInfo &)' being compiled

MSDN says that error 2558 might occur if your class's constructor is private, but mine is not. How can I fix this?

Ask me if you need more info.
ASKER CERTIFIED SOLUTION
Avatar of JackThornton
JackThornton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TookH
TookH

ASKER

Aha! It works perfectly. I guess that's what I get for using a Borland C++ 4.5 book as a reference. :)