Results 1 to 3 of 3

Thread: Omitting private part of a class definition

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

    Default Omitting private part of a class definition

    Just a quick question.

    Can you omit the private part of a class definition (inside the header files) when you distribute them together with a library for other users ? It seems to link and run fine, but I would like to be sure there are no issues. It would be ideal for me since I would like to hide the implementation details as much as possible.

  2. #2
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Omitting private part of a class definition

    In the general case you cannot. The problem is that the private parts of the class might be (and probably are) used to calculate the memory layout, thus if that is empty you will get into serious problem eventually.

    Another problem is that even private member functions might be exported, and thus might produce problems when they are not declared.


    My suggestion would be to follow the pimpl idiom to hide implementation detail. Check for example the Qt sources; you will find many "d-pointers", which follows the same principle.

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

    Raistlin (9th March 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Omitting private part of a class definition

    But you can just wrap/facade you class in a class that only calls the public members of your class - if that helps.

    K

Similar Threads

  1. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04
  2. Replies: 2
    Last Post: 4th May 2006, 19:17

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.