大萝卜BoBoBoBo~

导航

Problem E: 类的初体验(III)

 

 

#include <iostream>
using namespace std;

class Data
{
public:
    double xx;
public:
    Data(double x):xx(x){cout<<"Initialize a data "<<xx<<endl;}
    Data(){xx=0;cout<<"Initialize a data 0"<<endl;}
    double getValue(){return xx;}
    void showValue(){cout<<xx<<endl;}
};
int main()
{
    Data data1;
    double d;
    cin>>d;
    Data data(d);
    cout<<data.getValue()<<endl;
    data.showValue();
}

  

posted on 2020-04-20 21:47  我有一个大萝北  阅读(166)  评论(0编辑  收藏  举报