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