|
-
September 12th, 2002, 10:26 AM
#1
copy constructor question
I get an error when compiling the follow code:
class SomeType
{
public:
SomeType() { };
SomeType(SomeType& x) {};
};
std::vector<SomeType> array;
SomeType sometype1;
array.push_back(sometype1);
I get:
error C2558: class 'SomeType' : no copy constructor available
But I defined the copy constructor. If I comment out that line and uses the default copy constructor the code compiles.
-
September 12th, 2002, 10:37 AM
#2
Try passing a "const SomeType&".
If the default is sufficient, don't bother adding it at all.
Jeff
-
September 12th, 2002, 10:41 AM
#3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|