64,282
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
class A
{
public:
void f()
{
std::cout << "void f()" << std::endl;
}
void f() const
{
std::cout << "void f() const" << std::endl;
}
};
int main()
{
A a;
a.f();
system("pause");
return 0;
}
A a1;
a1.f();
输出:
void f()
const A a1;
a1.f();
输出:
void f() const