Jan 18, 2009

class foo { public: static int func(const char*& p) const; }; Why is this fragment incorrect ? The const function modifier is supposed to claim that

class foo {
public:
static int func(const char*& p) const;
};

Why is this fragment incorrect ?
The const function modifier is supposed to claim that the function will not modify any member variables (not a "mutator" if you want to).
But a static function, by definition, cannot access the member variables. So this function declaration doesn't make sense.

No comments:

Post a Comment