2

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);
}
nullptr
  • 505
  • 3
  • 10

0 Answers0