the reason my copy constructor isnt defined like: myClass(const myClass&)
is because myClass is a derived class for baseClass which is and abstract class defined as so:
1 2 3 4 5 6 7 8 9 10
class baseClass{
public:
int getID(int pos);
void setID(int pos, int val);
//... more member fucntions
private:
int ids[];
//..more private members
};
and in the copy constructor for myClass i am copying the values for baseClass::ids like so
1 2 3 4 5
myClass(myClass& ){
for(int i =0; i <3; ++i){
this->setID( i , p.ID(i));
}
}
but when i had the copy constructor defined as myClass(const myClass&) , my compiler told me myClass.cpp:25: error: passing 'const myClass' as 'this' argument of 'int baseClass::ID(int)' discards qualifiers
which i didnt know how to fix without removing the const specifier.
if you could tell me how i can get around this that would be great. and your other solution worked just fine.