复习题1

时间:2019-07-05 12:18:25   收藏:0   阅读:70

技术分享图片

#include<iostream>
 
using namespace std;
 
class Cup
{
private:
    int volume;
public:
    Cup(int v=0):volume(v)
    {
        cout<<"A cup of "<<volume<<" ml is created."<<endl;
    }
    Cup(const Cup& c):volume(c.volume)
    {
        cout<<"A cup of "<<volume<<" ml is copied."<<endl;
    }
    ~Cup()
    {
        cout<<"A cup of "<<volume<<" ml is erased."<<endl;
    }
    void setVolume(int v)
    {
        volume=v;
    }
};
int main()
{
    Cup c1;
    int i, j;
    cin>>i>>j;
    Cup c2(i), c3(c2);
    c3.setVolume(j);
    return 0;
}

 

原文:https://www.cnblogs.com/pxxfxxxx/p/11137497.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!