开发者

interesting situation in c++

#include <iostream>
#include <stdlib.h>
using namespace std;

int main(int argc, char* argv[]) {
  std:: cout<<"hello world";
  std::cout<<"i am surprise<"<<std::endl;
    return (EXIT_SUCCESS);
}

It is very strange because I am using netbeans in Ubuntu 10.04 and run this code. What happens here really makes me surprised; every line of code is marked with red line. For example:

  • first line indicates that it can't find indicator iostream or can't find f开发者_如何学JAVAile iostream;
  • second line can't find file stdlib;
  • third line unable to resolve identifier std and so on,
  • but it compiles fine and shows me the result "hello world i am surprise"

Please explain why is this happens?


Your IDE's "on the fly" correction tool might not be working correctly (because of bad settings or because fo bugs). I'm guessing it just don't have the access to the default includes.

Your compiler is a separate tool that have access to the includes so it will compile fine anyway.

Try to set the settings correctly or turn the underlining off, or even switch to a better IDE for C++.


The paths for "Code Assistance" are configured separately from your compiler includes. They are usually set when your tool chain is configured but you can check them from the Tools > Options dialog. If your includes are not in any of the paths listed, you will have to add the path. Below is an example of my configuration:

interesting situation in c++


Tools->Options->Code Assistance->C++ Compiler->add path C:\MinGW\bin. This solved the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜