Problem C: 类的初体验

#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();
}
浙公网安备 33010602011771号