顶层的const是会被忽略的 无法重载 重复定义
class A {
public:
void f(int* a) {
}
void f(int* const a) {
}
~A() {
}
};
error: ‘void A::f(int*)’ cannot be overloaded with ‘void A::f(int*)’
7 | void f(int* const a) {
}
底层的const是可以重载的
class A {
public:
void f(int* a) {
cout << 1 << endl; }
void f(const int* a) {
cout << 2 << endl