请大家找出错误

xiaozhang119 2004-05-02 07:45:29
#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错误为什么
...全文
56 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaozhang119 2004-05-03
  • 打赏
  • 举报
回复
我把 iomanip 加进去了 还是出现同样的错误
难道真的是编译器出毛病了
为什么编译别的还可以
编译器编译不同的程序有冲突吗?
newegg2002 2004-05-02
  • 打赏
  • 举报
回复
当我第一眼看到楼主的贴子以后.我就一个想法,,楼主的编译器挂了..
我有两次编译器出现过楼主所提到的
Error spawning cl.exe
的错误提示信息,,当时即使我建了simple application 也不行..还是有此错误,,没办法,,重装VC了..
楼主的代码错在两处.均是粗心所致:
1..定义完类tree后,别忘了;号啊.
2..height让你给写作heignt了..

fenghy2003 2004-05-02
  • 打赏
  • 举报
回复
使用dec/hex/oct是需要包含头文件iomanip的,楼主没有包含此头文件,能编译过去吗?
bm1408 2004-05-02
  • 打赏
  • 举报
回复
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);
}
cyllar 2004-05-02
  • 打赏
  • 举报
回复
#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);
yiminggw 2004-05-02
  • 打赏
  • 举报
回复
1.分号
2。 同上,dec是什么:)
zhaopeng3 2004-05-02
  • 打赏
  • 举报
回复
问一下
cout << dec << height << endl;
^^^
什么意思?
xiaozhang119 2004-05-02
  • 打赏
  • 举报
回复
#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错误为什么
xiaozhang119 2004-05-02
  • 打赏
  • 举报
回复
在C++中 private 不是可以省的吗
运行后还是出现同样的错误
cppmate 2004-05-02
  • 打赏
  • 举报
回复
#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;
}
rorot 2004-05-02
  • 打赏
  • 举报
回复
dec 是按10进制输出
hex 是按16进制输出
oct 是按8进制输出

可能是别得问题。
kwzzt 2004-05-02
  • 打赏
  • 举报
回复
代码本身没有问题,是编译器的问题
  • 打赏
  • 举报
回复
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,没错!

qyet 2004-05-02
  • 打赏
  • 举报
回复
只有误写,如楼上所说的~~
代码本身没有问题,有问题的话也只有找编译器的原因~
(有没有可能是工程建错了:))
==============================================输出
5
the tree is not tall。

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧