请大家找出错误
#include <iostream>
using namespace std;
class tree{
int height;
public :
tree(int h);
~tree();
}
tree::tree(int h){
height=h;
cout<<dec<<heignt<<endl;
}
tree::~tree(){
cout<<"the tree is not tall."<<endl;
}
void main(){
tree t(5);
}
编译时出现Error spawning cl.exe错误为什么
问题点数:20、回复次数:14Top
1 楼cppmate(cppmate)回复于 2004-05-02 08:12:33 得分 2
#include <iostream>
using namespace std;
class tree{
private:
int height;
public :
tree(int h);
~tree();
};////////////////////////
tree::tree(int h){
height=h;
cout<< dec << height << endl;////////////////////
}
tree::~tree(){
cout<<"the tree is not tall."<<endl;
}Top
2 楼xiaozhang119(刽子手119)回复于 2004-05-02 08:41:49 得分 0
在C++中 private 不是可以省的吗
运行后还是出现同样的错误Top
3 楼xiaozhang119(刽子手119)回复于 2004-05-02 08:43:16 得分 0
#include <iostream>
using namespace std;
class tree{
int height;
public :
tree(int h);
~tree();
};
tree::tree(int h){
height=h;
cout<< dec << height <<endl;
}
tree::~tree(){
cout<<"the tree is not tall."<<endl;
}
void main(){
tree t(5);
}
编译时出现Error spawning cl.exe错误为什么
Top
4 楼zhaopeng3(菜鸟)回复于 2004-05-02 09:05:08 得分 0
问一下
cout << dec << height << endl;
^^^
什么意思?Top
5 楼yiminggw(某某鸟人)回复于 2004-05-02 09:21:35 得分 0
1.分号
2。 同上,dec是什么:)Top
6 楼cyllar(cyllar)回复于 2004-05-02 09:24:37 得分 0
#include <iostream>
using namespace std;
class tree{
int height;
public :
tree(int h);
~tree();
};
tree::tree(int h){
height=h;
cout<< dec << height <<endl;
}
tree::~tree(){
cout<<"the tree is not tall."<<endl;
}
void main(){
tree t(5);
Top
7 楼bm1408(向va_list学习~不用VC好多年~)回复于 2004-05-02 09:28:27 得分 2
VC下调试能过!
#include <iostream>
using namespace std;
class tree{
int height;
public :
tree(int h);
~tree();
};
tree::tree(int h){
height=h;
cout<<dec<<height<<endl;
}
tree::~tree(){
cout<<"the tree is not tall."<<endl;
}
void main(){
tree t(5);
}Top
8 楼newegg2002(同志们,同胞们,大学的四年,是扎实基础的四年!!)回复于 2004-05-02 11:04:46 得分 9
当我第一眼看到楼主的贴子以后.我就一个想法,,楼主的编译器挂了..
我有两次编译器出现过楼主所提到的
Error spawning cl.exe
的错误提示信息,,当时即使我建了simple application 也不行..还是有此错误,,没办法,,重装VC了..
楼主的代码错在两处.均是粗心所致:
1..定义完类tree后,别忘了;号啊.
2..height让你给写作heignt了..
Top
9 楼qyet(少年心气)回复于 2004-05-02 13:15:08 得分 0
只有误写,如楼上所说的~~
代码本身没有问题,有问题的话也只有找编译器的原因~
(有没有可能是工程建错了:))
==============================================输出
5
the tree is not tall。
Top
10 楼zxs790501(沧海一粟)回复于 2004-05-02 14:55:25 得分 2
class tree{
int height;
public :
tree(int h);
~tree();
}
改为:(后面加分号)
class tree{
int height;
public :
tree(int h);
~tree();
};
还有拼写错误:
cout<<dec<<heignt<<endl;改为cout<<dec<<height<<endl;
都是大意!
默认类型为private,没错!
Top
11 楼kwzzt(kwzzt)回复于 2004-05-02 15:30:25 得分 0
代码本身没有问题,是编译器的问题Top
12 楼rorot(rorot)回复于 2004-05-02 15:50:11 得分 3
dec 是按10进制输出
hex 是按16进制输出
oct 是按8进制输出
可能是别得问题。Top
13 楼fenghy2003(fenghaiyang)回复于 2004-05-02 22:19:48 得分 2
使用dec/hex/oct是需要包含头文件iomanip的,楼主没有包含此头文件,能编译过去吗?Top
14 楼xiaozhang119(刽子手119)回复于 2004-05-03 18:40:07 得分 0
我把 iomanip 加进去了 还是出现同样的错误
难道真的是编译器出毛病了
为什么编译别的还可以
编译器编译不同的程序有冲突吗?Top




