Visual Studio 中的 lcr 游戏 c++ LINK 2019 错误
lcr game c++ LINK 2019 error in Visual Studio
我目前正在做一个周日的学校项目。 这是使用Visual Studio 2017 C++的LCR骰子游戏。 我无法通过 2 链接 2019 错误。我已经包含了定义和调用这些函数的所有实例的代码。 我试图改变我称呼它们的方式,并试图删除静态播放器::d勃起,但没有运气。 因为它是一个链接器错误,Visual Studio 直到编译时才会找到它。 我试图寻找答案,但我找不到任何特定于我的问题。任何帮助将不胜感激。 谢谢。 以下是确切的错误:
"LNK2019 unresolved external symbol "public: void __thiscall
Player::setName(void)" (?setName@Player@@QAEXXZ) referenced in function
_main LCR Game C:UsersdocmoDesktopSNHU filesIT 312 C++
ProgrammingLCR GameLCR GameLCR Game.obj 1"
和
"LNK2019 unresolved external symbol "public: static void __cdecl
Player::directions(void)" (?directions@Player@@SAXXZ) referenced in
function _main LCR Game C:UsersdocmoDesktopSNHU filesIT 312 C++
ProgrammingLCR GameLCR GameLCR Game.obj 1"
这是C++代码:
Player.h:
#pragma once
#include "stdafx.h"
#include <iostream>
#include "Dice.h"
class Player
{
public:
int chips;
int numPlayers;
std::string name = "";
Player() = default;
void setName();
void setChips();
int checkChips();
static void directions();
};
Player.cpp:
#include "stdafx.h"
#include "Player.h"
#include "Dice.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace System;
using namespace System::IO;
void Player::setName()
{
std::cin >> name;
}
...<more code>
void Player::directions() //display directions to player
...<more code>
LCR Game.cpp
// LCR Game.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <time.h>
#include "Dice.h"
#include "Player.h"
using namespace std;
...<more code>
for (int i = 0; i < numPlayers; i++) //loop to set names and chips for each
player
{
cout << "Enter player name: " << endl;
players[i].setName();
players[i].chips = 3;
}
Player::directions(); //display game rules to player
return 0;
}
我发现了我的问题。 这是一个初学者愚蠢的错误。 即使我将Microsoft Studio 中的文件添加到我的项目中,它也没有包含它们。 我必须在服务器资源管理器中选择每个文件,然后选择"项目",然后包含在项目中。 感谢您的所有帮助。
相关文章:
- 如何在MS Visual Studio 2019中运行QT UI
- LINK 尝试使用 OpenSSL evp aes 256 c++ 时出错
- 为什么它不适用于Visual 2019的原因
- Visual Studio 2019:插入多个C++风格的单行注释
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- 将IBM Rhapsody模型集成到VS 2019中
- C++17中函数模板中的静态数组初始化(MSVC 2019)
- 视觉studo 2019中的漫画和静态/动态绑定
- 如何使用c++在VS 2019上运行SQL查询
- vs 2015 constexpr变量不恒定,但与2019相比还好吗
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 将QT项目导入Visual Studio 2019会给我带来很多LNK2001错误
- 使用visual studio 2019正确设置tinycc,找不到库libtcc1-32.a
- 在Windows 10上使用Visual Studio 2019构建的Tesseract API c ++程序在Wind
- 如何为 C++ Visual Studio 2019 指定应用程序图标?
- 在Visual Studio 2019中保存时ReadDirectoryChangesW文件名的问题
- Visual Studio 中的 lcr 游戏 c++ LINK 2019 错误
- MFC C++ LINK 2019:未解析的外部符号"public: __thiscall
- 未解析的外部符号LINK 2019