begining c++ programming.
ok, im ridiculously new to C++ programming every time i try to put together and example, even ones from tutorials it says theres problems in it and it wont compile and run. do i need a diffrent compiler?
#include <iostream.h>
int main() { cout << "Hello World!\n"; return 0; }
even that wont work. and i copied and pasted directly from a site… it says: 1 C:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31, from first.cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from first.cpp um ok? what?
1 C:\Dev-Cpp\first.cpp from first.cpp
and last 32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #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 <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
i wouldent mind a programming mentor.
Try adding
markupusing namespace std;
or
markupusing std::cout;
underneath '#include <iostream>' or use 'std::cout' before each call to 'cout'
Example
markupstd::cout << "Hello World!\n";
Im not sure if that will solve the problem…I code in C mostly. I did code in C++ for a while a few years back but I wanted to learn more about the more complex elements such as pointers, dynamic memory allocation, etc so I went and started to learn C.
EDIT: Tested the OPs code as is and using '#include <iostream>' instead of '#include <iostream.h>' will remove the errors shown above but will add another error
5 C:\Documents and Settings\CyberLemming\My Documents\first.cpp `cout' undeclared (first use this function)
You would then have to add what I had stated above to remove that error. What the 'using ….' directive does is declares the classes, objects, functions in the standard library eg 'cout, cin, string, etc' so that they maybe used.
Again…Im not entirely sure on my explanation (Pieced together from various sources).
Another problem you may face is when you run the executable, command prompt will flash displaying the output for a spilt second. To solve this problem, the following url will help http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385
Regards CyberLemming
bl4ckc4t: No.. iostream.h is a deprecated header that as far as I remember, actually makes it so you don't need to include the std namespace. It is also deprecated as I've already stated as well and should be replaced with the standard iostream header file. Also, using namespace std; is not good coding practice. If the author of the thread reads my previous comment he'll realize the program is looking for the wrong entry point in the program.