Answer the question
In order to leave comments, you need to log in
Helloworld.cpp does not compile to g++
#include <iostream>
int main ()
{
cout << "Hello world\n";
}
g++ helloworld.cpp -o helloworld.cpp
helloworld.cpp: В функции «int main()»:
helloworld.cpp:5:3: ошибка: нет декларации «cout» в этой области видимости
helloworld.cpp:5:3: замечание: suggested alternative:
/usr/include/c++/4.6/iostream:62:18: замечание: «std::cout»
$
Answer the question
In order to leave comments, you need to log in
as an option to write
and compile using
run like
#include <iostream.h>
int main ()
{
cout << "Hello\n";
return 0;
}
g++ helloworld.cpp -Wno-deprecated -o helloworld
./helloworld
If you have an old target compiler that is incompatible with the standard, then develop on it, otherwise, in addition to this quite obvious glitch, you will get a dozen more non-obvious ones.
> But I was clearly told that the course paper and the exam is the second edition.
In my opinion, it is easier to convince the speaker than to do archeology and try to tune the 1991 compiler. Try creating a kostil.h file and declaring a namespace there. On the one hand, one inclusion will not be a serious deviation from the book, and on the other hand, it can solve the problem.
#ifdef CPP_NEW_VERSION
#define NAMESPACE using namespace std;
#else
#define NAMESPACE
#endif
And in the properties of your project, you can specify the desired define so that the namespace is connected.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question