Thread: Error in compiling

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    99

    Error in compiling

    I try compile this:
    Code:
    #include <iostream.h>
    
    int main()
    {
      cout << "Hello World!\n";
      return 0;
    }
    but when try compile i get:
    In file included from /usr/include/c++/3.2/backward/iostream.h:31,
    from 11.cpp:1:
    /usr/include/c++/3.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 <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
    why? THe program is being compile and work fine but why this erro?

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    because you are using an old header just use <iostream> instead. After that put using namespace std;
    Woop?

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    99
    THe book i use learn C++ in 21 days, says iostream.h, can't i find a book thatwill tell them right?
    i edit iostream and no i get errors too
    these erros:
    11.cpp: In function `int main()':
    11.cpp:5: `cout' undeclared (first use this function)
    11.cpp:5: (Each undeclared identifier is reported only once for each function it appears in.)
    thanks

  4. #4
    Registered User Kybo_Ren's Avatar
    Join Date
    Sep 2004
    Posts
    136
    Please read his response.

    He told you to put
    Code:
    using namespace std;
    after the #include part.
    The reason you got that error was because cout was not qualified.

    You can have a few different styles to it:
    Code:
    //Method 1
    #include <iostream>
    using namespace std;//qualifies all names to be in namespace std
    
    int main()
    {
        cout << "Hello, World!" << endl;
        return 0;
    }
    Code:
    //Method 2
    #include <iostream>
    using std::cout;
    using std::endl;//pre-qualifies cout and endl
    
    int main()
    {
        cout << "Hello, World!" << endl;
        return 0;
    }
    Code:
    //Method 3
    #include <iostream>
    
    int main()
    {
        std::cout << "Hello, World!" << std::endl;//inline qualification
        return 0;
    }
    I've heard people argue that method one is not the best to use, because it defeats the whole purpose of having a namespace, but I use it anyway (and just put using namespace ____ when I need to use a different namespace).

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    99
    The book doesn't say that

  6. #6
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    thats because the book is old and it does not use the latest standard..

  7. #7
    Registered User
    Join Date
    Jul 2004
    Posts
    99
    hell.
    where can i find the latest standard tutor? or book

  8. #8
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    you can get the latest book in a book store I assume..

  9. #9
    Registered User
    Join Date
    Jul 2004
    Posts
    99
    not here in Greece!
    in ineternet?

  10. #10
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    If you had searched the board a little you would have found 100's of threads which discuss abt e-book's tutorials etc to help beginners in C/C++

    http://cboard.cprogramming.com/showt...c%2B%2B+e-book

  11. #11

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling Issues
    By pc_doctor in forum C Programming
    Replies: 3
    Last Post: 11-30-2007, 10:00 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Problem Compiling
    By Flakster in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 01:09 AM
  4. Compiling
    By Dae in forum C++ Programming
    Replies: 7
    Last Post: 06-15-2005, 01:08 AM
  5. compiling and executing issue with lcc win32
    By GanglyLamb in forum C Programming
    Replies: 10
    Last Post: 12-22-2004, 02:24 PM