D
David Kevin
Hi,
I would be grateful if somebody could me help with following piece of
code:
#include "stdafx.h"
#include <iostream>
using namespace std;
class MyClass {
const void func() {}
const void func2(const MyClass* myClass) {
myClass->func();
}
};
int main()
{
return 0;
}
My compiler (Visual C++ 2008) complains that there is an error at line
8:
..\Problem.cpp(8) : error C2662: 'MyClass::func' : cannot convert
'this' pointer from 'const MyClass' to 'MyClass &'
Conversion loses qualifiers.
I would understand that if func could change myClass. But it is
declared as const. What happens?
Thanks in advance for responses,
Greetings.
I would be grateful if somebody could me help with following piece of
code:
#include "stdafx.h"
#include <iostream>
using namespace std;
class MyClass {
const void func() {}
const void func2(const MyClass* myClass) {
myClass->func();
}
};
int main()
{
return 0;
}
My compiler (Visual C++ 2008) complains that there is an error at line
8:
..\Problem.cpp(8) : error C2662: 'MyClass::func' : cannot convert
'this' pointer from 'const MyClass' to 'MyClass &'
Conversion loses qualifiers.
I would understand that if func could change myClass. But it is
declared as const. What happens?
Thanks in advance for responses,
Greetings.