#include <iostream>
#include <cstdlib>
using namespace std;
class R{
public:
R(int r1, int r2):m_iR1(r1), m_iR2(r2){}//常成员在初始化列表中进行初始化。
R(const R &r);//常引用
void display() const;//常成员函数
void display();
private:
int m_iR1;
const int m_iR2;//常数据成员
};
R::R(const R &r):m_iR2(r.m_iR2){
m_iR1 = r.m_iR1;
}
void R::display() const{
cout << m_iR1 << ";" << m_iR2 << endl;
}
void R::display(){
cout << m_iR1 << ";" << m_iR2 << endl;
}
int main(){
R r(1, 2);
r.display();
R r3(r);
r3.display();
const R r1(3, 4);//长对象,且不能被更新,
r1.display();
system("pause");
return 0;
}