0

Why does this compile? Even though the signature is different?

class A { void f(const int  a); };
void A::f(int a) {} //compiles fine

I've also tried other signature types, and got mixed results:

//Doesn't Compile:
class A { void f(const int*  a); };
void A::f(int* a) {}

class B { void f(const int&  a); };
void B::f(int& a) {}

//Compiles:
class C { void f(int* const  a); };
void C::f(int* a) {}

class D { void f(int& const  a); };
void D::f(int& a) {}

Why ?
Where in the C++ specs/standard is it written that the const doesn't matter in these cases?

I've checked on both Visual Studio and GCC.

Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
Yochai Timmer
  • 48,127
  • 24
  • 147
  • 185

0 Answers0