代码无法运行,尽管语法正确
Code fails to run, despite proper syntax
所以我试图在Visual Studio中运行这个,但它在输出控制台给了我几个错误:
1>------ Build started: Project: ConsoleApplication1, Configuration: Release x64 ------
1> stdafx.cpp
1> ConsoleApplication1.cpp
1>ConsoleApplication1.cpp(6): error C2039: 'cout': is not a member of 'std'
1> predefined C++ types (compiler internal)(209): note: see declaration of 'std'
1>ConsoleApplication1.cpp(6): error C2065: 'cout': undeclared identifier
1>ConsoleApplication1.cpp(6): warning C4554: '<<': check operator precedence for possible error; use parentheses to clarify precedence
1>ConsoleApplication1.cpp(6): error C2039: 'endl': is not a member of 'std'
1> predefined C++ types (compiler internal)(209): note: see declaration of 'std'
1>ConsoleApplication1.cpp(6): error C2065: 'endl': undeclared identifier
我的代码如下:
#include <iostream>
#include "stdafx.h"
void test(int x, int y)
{
std::cout << x + y << std::endl;
}
int main()
{
test(1, 2);
return 0;
}
您没有阅读您正在使用的程序的文档。
#include "stdafx.h"
必须先
改变头文件包含的顺序。预编译的头文件必须始终是源文件中的第一个非注释。
相关文章:
- 1d 智能指针不适用于语法 (*)++
- 运行同一解决方案的另一个项目的项目
- CMake-按正确顺序将项目与C运行时对象文件链接
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- 代码在main()中运行,但在函数中出现错误
- 助记符和指向成员语法的指针
- 有人能分解一下这个c++模板的语法吗
- C++避免重复声明的语法是什么
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- QMetaObject invokeMethod的基于函数指针的语法
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 如何在运行中期切换GTK CSS style_context
- 在C++中,如何同时运行两个语法命令?
- 在语法文件上运行C 的ANTL4解析器显示错误33:缺少代码生成模板非局部trrefheader
- Eclipse 在检查语法时看不到包含文件,但在构建或运行应用程序时会看到
- C/ c++和c#语法检查器,可以在文件列表上运行
- 代码无法运行,尽管语法正确
- 在运行时根据语法构建解析器
- 运行CLIREG32的正确语法