类相关问题

[复制链接]
1513|3
 楼主| sinadz 发表于 2012-7-20 22:29 | 显示全部楼层 |阅读模式
ST, DMA, ce, DM, ic
以下代码有问题吗?
include<iostream>
using namespace std;
class Mast
{
private:
int a;
int b;
public:
void IN_out();
};
void Mast::IN_out()
{
cout<<a<<endl<<b<<endl;
}
int main()
{
Mast T(10,20);
T.IN_out();
return 0;
}
火箭球迷 发表于 2012-7-20 22:43 | 显示全部楼层
没有两个参数的构造函数
yybj 发表于 2012-7-20 22:58 | 显示全部楼层
第一,最开头少了#
第二,公有函数那里void IN_out();根据你下面这里要定义两个参数,void IN_out(int,int);
第三,同理,这里void Mast::IN_out()也应该改为void Mast::IN_out(int a,int b)
第四,Mast T(10,20);
  T.IN_out();
这里不可以在定义类的一个对象的时候输入参数,,要在下面调用函数的输入,,
Mast T;
  T.IN_out(10,20);
秋天落叶 发表于 2012-7-20 23:08 | 显示全部楼层
缺少了构造函数
您需要登录后才可以回帖 登录 | 注册

本版积分规则

304

主题

2313

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部