visual-c++ - VC++编译时找不到exe
问题描述
尝试在 VS 中运行/调试我的 C++ 桌面应用程序时遇到问题。
我收到一条错误消息,告诉我找不到 DieGame.exe(在调试文件夹中)!
我还在控制台中收到许多错误(c2065),告诉我我在 DieGame.cpp 文件中有未声明的标识符?
有任何想法吗?
DieGame.cpp 文件:
#include "Die.h"
#include "pch.h"
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
Die die8 = createDie(8);
cout << "Rolling a D8: ";
for (int i = 0; i < 10; i++) {
cout << read(die8) << " ";
roll(die8);
}
cout << endl;
return 0;
}
模具.cpp 文件:
#include "pch.h"
#include "Die.h"
#include <cstdlib>
using namespace std;
int roll() {
return rand() % 6 + 1;
}
static int randomValue(int max) {
return rand() % max + 1;
}
Die createDie(int max) {
Die die;
die.max = max;
die.value = randomValue(max);
return die;
}
void roll(Die die) {
die.value = randomValue(die.max);
}
int read(Die die) {
return die.value;
}
Die.h 头文件:
#ifndef INCLUDED_DIE
#define INCLUDED_DIE
using namespace std;
int roll();
#endif
struct Die
{
int value;
int max;
};
Die createDie(int max);
void roll(Die die);
int read(Die die);
解决方案
In Die.h Header, move the #endif
line to the end of the file.
推荐阅读
- android - Android中服务和活动之间的交互
- xml - “找不到元素的声明”使用 XSD 进行验证
- spring - Spring Boot 应用程序未启动,也不例外
- javascript - Javascript - 如何在方法中获取/设置?(例如菠萝.is_a.fruit)
- javascript - React SPA with Express Backend API - 将 JWT 存储在本地存储中并限制 API 仅访问 SPA 的 Web 服务器 IP
- reactjs - 使用 react 路由器和 react-swipeable -views 在标签更改时更改 url
- oop - 除了 Animals 和 Shapes 之外,还有什么动态多态性的真实用例?
- java - Scala中的Java反射,将参数传递给函数时出错
- c++ - 代码块主页不会加载?
- c++ - c++ getline() 似乎没有正确运行,直到最后才读取该行