Can someone tell why i’m getting this error when compling this class?
class C
{
public:
void func(const C &obj)
{
//body
}
private:
int x;
};
void func2(const C &obj)
{
obj.func(obj);
}
int main() { /*no code here yet*/}
The C::func() method doesn’t promise that it won’t modify the object, it only promises that it won’t modify its argument. Fix:
Or make it a static function. Which sure sounds like it should be when it takes a C object as an argument.