help:关于类的问题
//create.h
#ifdef CREATE_H
#define CREATE_H
class createanddestroy{
public:
createanddestory(int);
~createanddestory();
private:
int data;
};
#endif
//create.ccp
#include<iostream.h>
#include"create.h"
createanddestroy::createanddestory (int value)
{
data=value;
cout<<"object"<<data<<"constructor";
}
createanddestroy::~createanddestroy()
{
cout<<"object"<<data<<"destuctor"<<endl;
}
//main.ccp
#include<iostream.h>
#include"create.h"
int main()
{
cout<<" (golbal created before main)"<<endl;
createanddestroy secnd(1);
return 0;
}
VC6.0提示:
Deleting intermediate files and output files for project 'creat - Win32 Debug'.
--------------------Configuration: creat - Win32 Debug--------------------
Compiling...
create.cpp
d:\book_c++_practice_qianneng\creat\create.cpp(3) : error C2653: 'createanddestroy' : is not a class or namespace name
d:\book_c++_practice_qianneng\creat\create.cpp(5) : error C2065: 'data' : undeclared identifier
d:\book_c++_practice_qianneng\creat\create.cpp(7) : warning C4508: 'createanddestory' : function should return a value; 'void' return type assumed
d:\book_c++_practice_qianneng\creat\create.cpp(8) : error C2653: 'createanddestroy' : is not a class or namespace name
d:\book_c++_practice_qianneng\creat\create.cpp(11) : warning C4508: 'createanddestroy' : function should return a value; 'void' return type assumed
main.cpp
D:\book_c++_practice_qianneng\creat\main.cpp(6) : error C2065: 'createanddestroy' : undeclared identifier
D:\book_c++_practice_qianneng\creat\main.cpp(6) : error C2146: syntax error : missing ';' before identifier 'secnd'
D:\book_c++_practice_qianneng\creat\main.cpp(6) : error C2065: 'secnd' : undeclared identifier
Error executing cl.exe.
creat.exe - 6 error(s), 2 warning(s)
请问问题处在那里啊?
问题点数:0、回复次数:3Top
1 楼SimplyBest(SimplyBest)回复于 2003-10-03 22:07:04 得分 0
你的类声明里的构造和析够函数名字写错了!!!!Top
2 楼hangdian(欧阳无敌)回复于 2003-10-03 22:25:30 得分 0
是 的,我也发现了,你那ro变or了Top
3 楼dingo2000(小鬼)回复于 2003-10-03 22:59:43 得分 0
createanddestroy::createanddestory (int value)
晕,前后两个单词不一样 !!!!Top




