第九周实践——阅读程序(3)

来源:互联网 发布:海康威视远程配置域名 编辑:程序博客网 时间:2024/06/06 02:03
/*
 *Copyright (c) 2016,烟台大学计算机学院
 *All rights reserved.
 *文件名称 :
*作    者 : 刘亚
*完成日期 : 2016年5月28号
*版 本 号 : v1.0
*问题描述 :  阅读程序,写出的程序的运行结果并理解
 *输入描述 :   无   
*程序输出 :   
 */





 #include <iostream> 
using namespace std; 
class AA 
{
public: 
    AA(int i,int j)  
    { 
        A=i; 
        B=j; 
        cout<<"Constructor\n"; 
    } 
    AA(AA &obj)  
    { 
        A=obj.A+1; 
        B=obj.B+2; 
        cout<<"Copy_Constructor\n"; 
    } 
    ~AA() { 
        cout<<"Destructor\n"; 
    } 
    void print() 
    { 
        cout<<"A="<<A<<",B="<<B<<endl; 
    } 
private: 
    int A,B; 
}; 
int main() 

    AA a1(2,3); 
    AA a2(a1); 
    a2.print(); 
    AA *pa=new AA(5,6); 
    pa->print(); 
    delete pa; 
    return 0; 


0 0