简体   繁体   English

Eclipse C ++“#include”和“使用名称空间”错误

[英]Eclipse C++ “#include” and “using namespace” errors

My aunt gave me a book about c++ (for beginners). 我的姨妈给了我一本关于c ++的书(适合初学者)。 It's nice and so I wanted to test one of those code samples. 很好,所以我想测试这些代码示例之一。 But I am just getting errors. 但是我只是出错了。 I didn't find anything that could help me on Google or so. 我在Google上找不到任何可以帮助我的东西。 I am using Eclipse Mars.1 C++ and MinGW. 我正在使用Eclipse Mars.1 C ++和MinGW。

Code: 码:

    /*
 * Erstes_Programm.cpp
 *
 *  Created on: 26.12.2015
 *      Author: Luca
 */

// Erstes Programm
#include <iostream>
using namespace std;
int main() {
    cout << "It's just a test!" << endl;
    return 0;
}

I am getting those errors: 我收到那些错误:

Using namespace: 使用名称空间:

Description Resource Path Location Type    
expected ';' before ':' token   
Erstes_Programm.cpp /Programmieren C++ (Einführung)    
line 10    
C/C++ Problem

AND

Description Resource Path Location Type   
expected unqualified-id before ':' token    
Erstes_Programm.cpp /Programmieren C++ (Einführung)   
line 10  
C/C++ Problem

Hope somebody can help me? 希望有人可以帮助我吗?

Here is a screenshot: 这是屏幕截图:

屏幕截图

EDIT: PROBLEM SOLVED!! 编辑:问题已解决! I don't know WHAT I did, but it's solved I'm not getting any errors and everything works perfectly. 我不知道我做了什么,但是解决了我没有遇到任何错误,并且一切正常。 Thanks for everybody who wanted to help 感谢所有想要帮助的人

The first line in the screenshot doesn't make any sense. 屏幕截图中的第一行没有任何意义。 Remove it. 去掉它。 The rest looks fine. 其余的看起来不错。 And in the future, post text , not screenshots. 将来,请发布文字 ,而不是屏幕截图。

Instead work on X-code rather then eclipse for C++. 取而代之的是使用X代码而不是C ++的Eclipse。 Visual studio is most recommend. 最推荐使用Visual Studio。 For Your problem, I think you got to play with the library, something must not be supported, other then that your code look fine. 对于您的问题,我认为您必须使用该库,不得支持某些东西,否则您的代码看起来会很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM