| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1200 人关注过本帖
标题:有关类的一些问题请大家指教啊
只看楼主 加入收藏
方程式
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2004-7-6
收藏
 问题点数:0 回复次数:4 
有关类的一些问题请大家指教啊

写个小程序如下: #include <iostream.h> class XXX { private : int a; int b; public: XXX(); void w(int,int); void s(); };

void XXX::w(int x,int y) { a=x;b=y; } void XXX::s() { cout <<"\n"<<a<<"\n"<<b; } void main() { XXX n; int a,b; cout<<"input a,b:"; cin >> a>>b; n.w(a,b); n.s();

} 编译通过了,但按F7后出现如下错误: -------------------Configuration: 6 - Win32 Debug-------------------- Compiling... 6.cpp Linking... 6.obj : error LNK2001: unresolved external symbol "public: __thiscall XXX::XXX(void)" (??0XXX@@QAE@XZ) Debug/6.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe.

6.exe - 2 error(s), 0 warning(s) 请指教一下!!!

搜索更多相关主题的帖子: 指教 
2004-07-16 02:17
C++大粉丝
Rank: 4
等 级:贵宾
威 望:10
帖 子:477
专家分:0
注 册:2004-4-23
收藏
得分:0 

你的构造函数没有实现.

XXX:XXX(){}


I am a big fan of c plus plus.
2004-07-16 08:54
kuangjingbo
Rank: 1
等 级:新手上路
帖 子:312
专家分:0
注 册:2004-4-24
收藏
得分:0 

楼上说的对,你只声明了构造函数,但是没有实现


永不放弃!
2004-07-17 20:07
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 

#include <iostream.h>

class XXX { private : int a; int b; public: XXX(){} // when the default constructor don't manipulate the date, then you need not write it // the compiler will do it automatic for you. void w(int,int); void s(); };

void XXX::w(int x,int y) { a=x;b=y; }

void XXX::s() { cout <<"\n"<<a<<"\n"<<b; }

int main() { XXX n; int a,b; cout<<"input a,b:"; cin >> a>>b; n.w(a,b); n.s(); return 0;

}


自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2004-07-20 04:33
金多虾
Rank: 2
等 级:论坛游民
帖 子:153
专家分:99
注 册:2009-6-9
收藏
得分:0 
构造函数没有进行功能的实现!
2009-08-04 21:54
快速回复:有关类的一些问题请大家指教啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015299 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved