Sunday, May 10, 2009

Question 4 anyone who knows c++ (please help)?

I am trying to learn c++ and am starting in a basics c++ book. My first Project will be to make a source file with this code:


// myprog.cpp


// my first c++ program


#include %26lt;iostream.h%26gt;


int main()


{


cout %26lt;%26lt; "My first C++ program.\n";


return 0;


}





I am using Bloodshed Dev-C++ version 4.9.9.2





When I try to compile and run the file as instructed in the book i get the following error:





32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\ba... #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 %26lt;X%26gt; header for the %26lt;X.h%26gt; header for C++ includes, or %26lt;iostream%26gt; instead of the deprecated header %26lt;iostream.h%26gt;. To disable this warning use -Wno-deprecated.





I don't know what i did wrong and for a complete beginner in C++ this type of thing is very intimidating. I don't know what to do. Please help.

Question 4 anyone who knows c++ (please help)?
The above two respondants gave you good answers.





I will just add this: do not be intimidated by error and warning messages. They are only sign posts. Frequently, the smallest, simplest mistake can generate line after line of error messages that seem to be intent on punishing you for your foolishness. In fact, the compiler is just lost. Deal with the top-most error message and then recompile.





It will get easier.
Reply:Look at what the error says:





"Examples include substituting the %26lt;X%26gt; header for the %26lt;X.h%26gt; header for C++ includes, or %26lt;iostream%26gt; instead of the deprecated header %26lt;iostream.h%26gt;"





So do that. Your third line should be


#include %26lt;iostream%26gt;





The other errors you were getting are because of this error (i.e.: "cout" is declared in iostream, which you aren't successfully importing.)
Reply:I'd try shutting it and starting a new project. I just copied and pasted the code into DevC++ and it worked fine for me (except that you need a pause so you can actually see the console).


No comments:

Post a Comment