注册 登录
编程论坛 C++教室

求助 “设计出能使用如下测试程序的类 ” 答案

helen0581 发布于 2008-11-23 12:55, 939 次点击
下面是一类的测试程序,设计出能使用如下测试程序的类。
void main( )
{
 test  x;
 x.initx(300,200);
 x.printx();
}
输出结果:300-200=100
2 回复
#2
saltss2008-11-23 15:01
class test{
    int a,b;
public:
    void initx(int x,int y){a=x;b=y;}
    void printx(){cout<<a<<"-"<<b<<"="<<a-b<<endl;}
};
#3
crazycoder2008-11-23 15:51
1