c++ - 在 visual studio 中创建了一个空项目,它似乎不再打开控制台?

标签 c++ visual-c++ c++17

我在使用控制台应用程序模板创建的项目中遇到错误,因此决定使用空模板重新创建项目。这似乎已经解决了我收到的“未解析的外部符号”错误,但现在当我调用 cout 进行输出时控制台不会打开。

#include<iostream>
#include<string>
#include <fstream>
#include <vector>
#include "pch.h"
#include "word.h"
#include "dictionary.h"

using namespace std;

int main()
{
    Dictionary dic;
    dic.loadDictionary();
    cout >> "Hey\n" >> endl;
    cout.flush();
}

有两个正在使用的类文件,但由于没有错误,我不认为需要查看它们。

感谢您的帮助!

编辑:收到错误的原始项目是“LNK2019 未解析的外部符号”public: void __thiscall Dictionary::loadDictionary(void)“(?loadDictionary@Dictionary@@QAEXXZ) 在函数 _main ConsoleApplicationASS 中引用”

最佳答案

使用 <<而不是 >> .也放getch()最后让控制台等待您的输入,以便您可以看到控制台输出。

对问题进行编辑后,您应该 read about solving the LNK2019 .

关于c++ - 在 visual studio 中创建了一个空项目,它似乎不再打开控制台?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55683073/

相关文章:

c++ - 可以在运行时优化浮点零乘法吗?

与枚举相关的 C++ LNK2005 错误

visual-c++ - 错误 C2664 : 'sprintf' : cannot convert parameter 1 from 'std::string' to 'char *'

C++:查找满足谓词的元组的第一个元素

c++ - 如何打印 std::map<int, std::vector<int>>?

c++ - 如何为 sql 查询准备 C++ 字符串

c++ - 在flex中匹配C风格多行注释的最佳解决方案?

c++ - 迭代合并 std::unordered_map

c++ - 关于template和typename的问题

visual-c++ - 基本代码布局问题