[Dev-C++] Copy Constructors and Overloaded Assignment Operators
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Matthew H. <mhi...@sy...> - 2002-07-20 20:09:46
|
Hello guys,
Just a quick question...
I'm having a rough time getting some copy constructors and overloaded
assignment operators to work. I've had a look through my stuff (Ivor
Horton - Wrox - Beginning C++; Steve Oualline - O'Reilly - Practical C++
Programming), but to no avail.
I feel like I'm asking how to unsubscribe here, so please be gentle... 8-)
(By the way, can't an Admin just set up a list filter to clobber these
guys... )
Here's the error... (others are similar)
"passing 'const Test' as 'this' argument of 'int Test::getData()'
discards qualifiers
[code begins]
// Copy Constructor
Test::Test(const Test& TestCopy){
data = TestCopy.getData();
data2 = TestCopy.getData2();
}
// Operator =
Test& Test::operator=(const Test& Test2){
data = Test2.getData();
data2 = Test2.getData2();
return *this;
}
[code ends]
I've tried using my set functions (what I want to do anyhow...),
i.e. this.setData(Test2.getData()); // this omitted too...
I've also tried...
data = Test2->getData();
I'm going to keep looking, but a quick pointer to a good discussion
on this would be great (or a good discussion).
Any help would be greatly appreciated.
|