G
Gernot Frisch
Hi,
assume:
MyClass mc;
const MyClass& Rmc = mc;
mc->GetPtr()->AlterData();
Rmc->GetPtr()->ReadData(); // Here's the error
now: I have defines MyClass as:
class MyClass
{
public:
MyClass() {};
MyClass* GetPtr() {return this;}
const MyClass* GetPtr() const {return this;}
void AlterData() {}
void ReadData() const {}
};
However, this does not work.
Error C2440: 'const class MyClass*' cannot be converted to 'class
MyClass *'
What did I do wrong? Is the compiler always using the first one? Do I
have to use 2 function names?
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}
________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
assume:
MyClass mc;
const MyClass& Rmc = mc;
mc->GetPtr()->AlterData();
Rmc->GetPtr()->ReadData(); // Here's the error
now: I have defines MyClass as:
class MyClass
{
public:
MyClass() {};
MyClass* GetPtr() {return this;}
const MyClass* GetPtr() const {return this;}
void AlterData() {}
void ReadData() const {}
};
However, this does not work.
Error C2440: 'const class MyClass*' cannot be converted to 'class
MyClass *'
What did I do wrong? Is the compiler always using the first one? Do I
have to use 2 function names?
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}
________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com