I want to use "Dev-C++" for compile c++ codes. So I download and install it, and write this code:
#include <iostream.h>
main () {
cout << "124";
}
but when I compiled it, it said:
In file included from E:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from [myfile path]\Untitled1.cpp:1: E:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.
After I saw errors, I change my code to this code:
#include <iostream>
main () {
cout << "124";
}
but it said again that errors.
I compile first code easily in Turbo C++, BUT in Dev-C++ ...
What can I do?
First, make sure you write out the full definition of main
, including the int
return type. Leaving out the return type is an old, antiquated practice which doesn't fly these days.
Second, in the new-style headers—the ones missing the .h
extension—the standard library is under the std
namespace. There are two ways to make your program work:
1. Add an std::
qualifier to cout
.
#include <iostream>
int main () {
std::cout << "124";
}
2. Add a using
declaration to allow unqualified references to the std
namespace.
#include <iostream>
using namespace std;
int main () {
cout << "124";
}