return与析构函数

#include <iostream>
using namespace std;
class a{
private:
    int i;
public:


    a(int n):i(n){
        cout<<"constructing"<<endl;
    }
    ~a(){
        cout<<"destructing"<<endl;
    }
    int get_i(){
        return i;
    }
};
int aqr_it(a a){
    return a.get_i()*a.get_i();
}
int main(){
    a a(10);
    cout<<a.get_i()<<endl;
    cout<<aqr_it(a)<<endl;
    return 0;

}

结果:

constructing
10
100
destructing
destructing

posted @ 2018-04-30 17:31  UnderScrutiny  阅读(326)  评论(0编辑  收藏  举报