const not enforced in definition of member function

Viewed 47

I'm wondering why the following code compiles when the definition of the member function does not have the same signature as the declaration (definition is missing const).

#include <iostream>

class myClass {
public:
    void myFunc(const int);
};

void myClass::myFunc(int a){
    a += 1;
    std::cout << a << "\n";
}

int main()
{
  myClass myObject;
  myObject.myFunc(5);
}
0 Answers
Related