免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1405 | 回复: 5
打印 上一主题 下一主题

[函数] 构造函数与析构函数的调用,链接时出了问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-03-14 16:17 |只看该作者 |倒序浏览
class CWord
{
  public:
    //## Constructors (generated)
      CWord();
      CWord(const CWord &right);

    //## Destructor (generated)
      ~CWord();
}
CWord::CWord()
{
  //## begin CWord::CWord%3BF87746001B_const.body preserve=yes

  //## end CWord::CWord%3BF87746001B_const.body
}

CWord::CWord(const CWord &right)
{
  //## begin CWord::CWord%3BF87746001B_copy.body preserve=yes
        wstrWord=right.getWord();
        dwId=right.getId();
        dfFreq=right.getFreq();
        dfTfIdf=right.getTfIdf();
        uiPos=right.getPos();
        vecSense=right.getSense();
}

在声明了CWord类之后,这样调用他的构造函数可以吗?
CWord* wordtemp = new CWord;
链接的时候会出这样的错误
CDictionary.o(.text+0xa37): In function `CDictionary::loadDic(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
CDictionary.cpp: undefined reference to `CWord::CWord()'

论坛徽章:
0
2 [报告]
发表于 2006-03-14 16:20 |只看该作者
析构函数的定义同上,实现为
CWord::~CWord()
{
  //## begin CWord::~CWord%3BF87746001B_dest.body preserve=yes
  //## end CWord::~CWord%3BF87746001B_dest.body
}

函数中对析构函数的调用为
CWord * pword=0;
......
delete pword;
链接时的错误如下
CDictionary.o(.text+0x6e3): In function `CDictionary::deleteWord(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&)':
CDictionary.cpp: undefined reference to `CWord::~CWord()'

论坛徽章:
0
3 [报告]
发表于 2006-03-14 23:31 |只看该作者
在线等

论坛徽章:
0
4 [报告]
发表于 2006-03-15 08:31 |只看该作者
你这个错误提示应该是有语法错误吧???

仔细检查下声明和定义!

论坛徽章:
0
5 [报告]
发表于 2006-03-18 23:05 |只看该作者
谢谢

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
6 [报告]
发表于 2006-03-18 23:23 |只看该作者
你是怎么链接得呀?
这个你都不说。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP