OJ第二批——Problem G:驾驭const

来源:互联网 发布:如何查看知乎推送 编辑:程序博客网 时间:2024/05/16 12:49

问题及代码:

 

#include <iostream>using namespace std;class Test{private:    int x;    const int y;//************* begin *****************public:    Test(int a, int b);    void printxy() const ;   //(1)} ;Test::Test(int a, int b):x(a),y(b) {} ; //(2)void Test::printxy() const  //(3){    cout<<"x*y="<<x*y<<endl;}//************* end *****************int main(){    int x1,x2;    cin>>x1>>x2;    const Test t(x1,x2);    t.printxy( );    return 0;}


 

 

运行结果:

0 0
原创粉丝点击