Because:
this
is a const pointer to the current obj object.
Therefore, you can either make func as const:
class C { public: void func(const C &obj) const {
OR
you can remove the pointer constant this as follows:
class C { public: void func(const C &obj) {
Hope this helps.
source share