问题描述
我刚刚开始使用C ++语法,并构建了一个非常简单的代码来进行测试:
我有以下文件:
shoe.h(包含"TieLaces"的声明)
test.cpp(包含"main")
shoe.cpp(包含在"test.cpp"中使用的函数"TieLaces")
Test.cpp和shoe.cpp是同一程序集的一部分(即shoe.cpp不是外部库的一部分).
我正在使用MS VC ++2008.它可以很好地编译,但是链接器部分报告了有关函数"TieLaces"的未解决的令牌".
我知道外部库必须在链接器配置"部分中引用外部库,但是无法引用内部函数(我知道).那么,为什么会发生此错误?
Shoe.cpp:
I am just getting used C++ syntax and have constructed a very simple bit of code for testing:
I have the following files:
shoe.h (contains declaration for "TieLaces")
test.cpp (contains "main")
shoe.cpp (contains a function "TieLaces" which I make use of in "test.cpp")
Test.cpp and shoe.cpp are part of the same assembly (i.e., shoe.cpp is not part of an external library).
I am using MS VC++ 2008. It compiles fine, but the Linker section reports an "unresolved token" with regard to function "TieLaces".
I know that external libraries must be referenced in the Linker config section for external libs, but there is no way to reference an internal function (that I know of). So, why is this error occurring?
Shoe.cpp:
#include "stdafx.h"
#include "Shoe.h"
#define TRUE 1;
#define FALSE 0;
Shoe::Shoe() {}
Shoe::~Shoe() {}
bool TieLaces(void)
{
bool Done = TRUE;
return Done;
}
Test.cpp:
Test.cpp:
#include "stdafx.h"
#include "Shoe.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
Shoe newShoes;
newShoes.TieLaces();
return 0;
}
Shoe.h:
Shoe.h:
class Shoe
{
public:
Shoe();
~Shoe(void);
bool TieLaces(void);
};
推荐答案
bool Shoe::TieLaces(void)
{
bool Done = TRUE;
return Done;
}
这篇关于当函数是同一程序集的一部分时,C ++无法解析的令牌错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!