标题:error LNK2001
只看楼主
独孤剑魔
Rank: 1
等 级:新手上路
帖 子:103
专家分:0
注 册:2008-8-5
 问题点数:0 回复次数:1 
error LNK2001
一下是原题:
typedef string Type;
Type initVal();
class Exercise
{
public:
    typedef double Type;
    Type setVal(Type);
    Type initVal();
private:
    int val;
};
Type Exercise::setVal(Type parm)
{
         val = parm+initVal();
}


这是我更改后的:
typedef string Type;
Type initVal();
class Exercise
{
public:
    typedef double Type;
    Type setVal(Type);
    Type initVal();
private:
    int val;
};
Exercise::Type Exercise::setVal(Exercise::Type parm)
{
    val = parm+Exercise::initVal();
    return val;
}


一下是错误消息
--------------------Configuration: new1 - Win32 Debug--------------------
Compiling...
new1.cpp
Linking...
new1.obj : error LNK2001: unresolved external symbol "public: double __thiscall Exercise::initVal(void)" (?initVal@Exercise@@QAENXZ)
Debug/new1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

new1.exe - 2 error(s), 0 warning(s)
搜索更多相关主题的帖子: private public double 
2008-10-15 15:19
独孤剑魔
Rank: 1
等 级:新手上路
帖 子:103
专家分:0
注 册:2008-8-5
得分:0 
关于那个initVal()函数,我已经加上了::,指明使用类中的,为什么会这样?
2008-10-15 15:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-238441-1-1.html




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

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