错误LNK2019:未解析的外部符号新手需要提示
error LNK2019: unresolved external symbol newbie needs tip
我只是在C++中探索一些更高级的编码,所以想象一下当我无法解决这个问题时的沮丧:
1>Main.obj : error LNK2019: unresolved external symbol "int __cdecl playerAtk(void)" (? playerAtk@@YAHXZ) referenced in function _main
1>C:UsersHezekiah Detincdocumentsvisual studio 2010ProjectsCustom_1DebugCustom_1.exe : fatal error LNK1120: 1 unresolved externals
我曾尝试在这里寻找答案,但我找到的解决方案太具体了,对我没有任何用处。
如果有人能回答;通常是什么原因导致此问题?修复它有哪些解决方案?
这是我的主要.cpp;
//Custom 1
//Include files that may be used. will cut out unused files in release.
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include "EnemyBaseClass.h"
#include "PlayerBaseClass.h"
using namespace std;
int main()
{
Enemy emy;
Player plr;
emy.enemyAtk();
emy.enemyDef();
emy.enemyHp();
plr.playerAtk();
plr.playerDef();
plr.playerHp();
int playerAtk();
cout << playerAtk();
cout << "You're attacked by a Monster!n";
system(" pause ");
return 0;
}
如果我需要发布我的标题或其他 _.cpp 文件,请告诉我。
你声明并使用playerAtk作为一个函数(没有实现,因此是未定义的引用)
改变
int playerAtk();
...
cout << playerAtk();
自
int playerAtk;
...
cout << playerAtk;
(您可能想要初始化变量)
错误很简单:您正在使用已声明的函数,但尚未编写任何定义(实现)。检查源 (.cpp) 文件。
相关文章:
- 在C++中,将大的无符号浮点数四舍五入为整数的最佳方法是什么
- 有符号的int和int-有没有一种方法可以在C++中区分它们
- 将无符号char*转换为std::istream*C++
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- vscode g++链路故障:体系结构x86_64的未定义符号
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 如何理解将半精度指针转换为无符号长指针和相关的内存对齐
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 使用gcc从静态链接的文件中查找可选符号
- C++中无符号字符溢出
- 我是C++编程的新手,这些代码之间有什么区别,我应该使用哪一个
- 使用无符号字符数组有效存储内存
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- VC++本机单元测试,找不到调试符号
- 为什么我必须在C++中添加一个赋值符号来声明一个数组
- 我是c ++的新手,你能解释一下在这种情况下的指针吗
- 检查TCHAR数组输入是否为带符号整数C++
- 用符号版本替换对函数的所有调用
- 未解析的外部符号_MsiLocateComponentW@12.
- 错误LNK2019:未解析的外部符号新手需要提示