Results 1 to 3 of 3

Thread: Adding C++ standard header files to the project

  1. #1
    Join Date
    Feb 2016
    Posts
    15
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Adding C++ standard header files to the project

    [I]Hi all ,

    Iam trying to add standard c++ header file to my project.Here is my code

    Qt Code:
    1. #include <iostream>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication a(argc, argv);
    6. MainWindow w;
    7. w.show();
    8.  
    9.  
    10. cout << "hello" ;
    11.  
    12. return a.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    Im adding iostream though i'm getting error.
    errors are : 'cout' was not declared in this scope
    cout << "hello" ;
    ^
    But when i put the cursor on the include file it is showing the correct path of the iostream standard c++ file /usr/include/c++/4.8/iostream ^

    then how to solve error
    Last edited by anda_skoa; 15th February 2016 at 09:18. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Adding C++ standard header files to the project

    cout is not a global symbol, it is part of the "std" namespace.
    E.g.
    Qt Code:
    1. std::cout << "hello";
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Feb 2016
    Posts
    16
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Adding C++ standard header files to the project

    Otherwise,you could make a
    Qt Code:
    1. using namespace std;
    To copy to clipboard, switch view to plain text mode 
    which also gives you the right scope.
    From programming point of view this should be avoided and the solution of "anda_skoa" is the best one!!!

Similar Threads

  1. Qt Creator Adding files to cmake project
    By xadian in forum Qt Tools
    Replies: 1
    Last Post: 1st April 2013, 15:18
  2. Replies: 3
    Last Post: 20th March 2013, 17:38
  3. Adding SVG files to the project
    By jeff28 in forum Qt Programming
    Replies: 0
    Last Post: 15th August 2012, 14:27
  4. Replies: 11
    Last Post: 26th May 2010, 05:33
  5. visual studio project files - adding extra files
    By luf in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 21:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.