大萝卜BoBoBoBo~

导航

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

  

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