当前位置:编程学习 > VC++ >>

关于VC++的问题

开始我用VC6光编译卡死就用VS2008

#include<iostream>
class Test{
public:
int a;
int b;
Test(){
}

Test(int i ,int j){
a = i;
b = j;
}

~Test(){}

void set(int i,int j){
this->a = i;
this->b = j;
}

//void out(){
//cout<<a<<endl<<b<<endl;
//}
}


int main()
{
Test test(5,5);
//test.out();
return 0;

}

出了一堆错误

1>------ 已启动生成: 项目: Test, 配置: Debug Win32 ------
1>正在编译...
1>test.cpp
1>c:\documents and settings\董剑峰\桌面\初级篇1.3.8\test\test.cpp(27) : error C2628: “Test”后面接“int”是非法的(是否忘记了“;”?)
1>c:\documents and settings\董剑峰\桌面\初级篇1.3.8\test\test.cpp(28) : error C3874: “main”的返回类型应为“int”而非“Test”
1>c:\documents and settings\董剑峰\桌面\初级篇1.3.8\test\test.cpp(31) : error C2664: “Test::Test(const Test &)”: 不能将参数 1 从“int”转换为“const Test &”
1> 原因如下: 无法从“int”转换为“const Test”
1> 无构造函数可以接受源类型,或构造函数重载决策不明确

提示什么main返回值我用void 和int 都不行,还有找不到io库,怎么回事?

怎么解决?错误提示信息根本没用,看不出问题在哪

还有个地方提示是否忘记了分号,我看了都没有少啊

答案:

一个类的述写,终以“;”结束

试试这个:

#include<iostream>
class Test
{
public:
int a;
int b;
Test(){
}

Test(int i ,int j)
{
a = i;
b = j;
}

~Test(){}

void set(int i,int j)
{
this->a = i;
this->b = j;
}

};


int main()
{
Test test(5,5);
//test.out();
return 0;

}

还有你的数据属性的处理,应该注意一下,

public,与private的分析

类的结尾要加 ;

上一个:VC++鼠标的问题!
下一个:VC++问题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,