C++常引用作为函数的参数学习笔记

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;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章