Results 1 to 3 of 3

Thread: Forward declaration with std namespace

  1. #1
    Join Date
    Aug 2006
    Posts
    44
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Forward declaration with std namespace

    I am writing a software development kit and would like to use as much forward declarations as possible. One of the used classes is std::fstream, but I do not want to include <fstream> in the header files, since I do not want external includes.

    However, how to use a forward declaration as the following without using the std notation ? I could use a void* as work-around, but that does not sound like a clean solution.

    Qt Code:
    1. class SmallClass;
    2. //class std::fstream; is not accepted by the compiler, for obvious reasons
    3.  
    4. class Bigclass {
    5. public:
    6. ...
    7.  
    8. private:
    9. SmallClass* smallObject_;
    10. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2006
    Location
    Switzerland
    Posts
    52
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Forward declaration with std namespace

    Quote Originally Posted by Raistlin View Post
    [...] One of the used classes is std::fstream, but I do not want to include <fstream> in the header files, since I do not want external includes.

    However, how to use a forward declaration as the following without using the std notation ?
    You can use iosfwd header file:
    Qt Code:
    1. #include <iosfwd>
    To copy to clipboard, switch view to plain text mode 
    . See description.
    The Wheel weaves as the Wheel wills.

  3. The following user says thank you to danadam for this useful post:

    Raistlin (5th March 2007)

  4. #3
    Join Date
    Aug 2006
    Posts
    44
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Forward declaration with std namespace

    Exacly what I need, thanks

Similar Threads

  1. Why forward declaration ?
    By probine in forum General Programming
    Replies: 3
    Last Post: 26th January 2007, 18:22
  2. Compile Errors
    By luffy27 in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2006, 05:26

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.