
#include <iostream>
using namespace std;
class Data
{
private:
double x;
public:
void init(double xx){x = xx;}
double getValue(){return x;}
void showValue(){ cout << x <<endl;}
};
int main()
{
Data data;
double d;
cin>>d;
data.init(d);
cout<<data.getValue()<<endl;
data.showValue();
}
原文:https://www.cnblogs.com/Begin-Again/p/12740608.html