1.常对象定义:使用const关键字修饰的对象称为常对象定义格式 类名 const 对象名称(参数列表)
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class A{
private:
int x;
int y;
public:
A(int x1,int y1):x(x1),y(y1){
Print();
}
void Print(){
cout<<x<<"\t"<<y<<endl;
}
};
int main(int argc, char** argv) {
A const a(32,45);
return 0;
}