4.3.4 const修饰成员函数
#include <iostream>
using namespace std;
class person
{
public:
void showperson() const
{
this->m_b = 100;
}
int m_a;
mutable int m_b;
};
void test01()
{
person p;
p.showperson();
}
void test02()
{
const person p;
p.m_b = 100;
p.showperson();
}
int main4_3_4()
{
system("pause");
return 0;
}
4.3.3空指针访问成员函数
#include <iostream>
using namespace std;
class person
{
public:
void showclassname()
{
cout << "eeee" << endl;
}
void showpersonage()
{
cout << "age: " << m_age << endl;
}
int m_age;
};
void test01()
{
person *p = NULL;
p->showpersonage();
}
int main4_3_3()
{
test01();
system("pause");
return 0;
}