Results 1 to 3 of 3

Thread: class in the class

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default class in the class

    Guys,

    I have some structure definition inside my class and it seems to be c like if your using struct so I want to change my style. but what is the best style to do this.

    below is my old code:
    Qt Code:
    1. class B
    2. {
    3. public:
    4. typedef struct s_A
    5. {
    6. int X;
    7. int Y;
    8. int Z;
    9. } t_A;
    10. protected:
    11. private:
    12. };
    To copy to clipboard, switch view to plain text mode 

    I want to change this to

    Qt Code:
    1. class B
    2. {
    3. public:
    4. class t_A
    5. {
    6. public:
    7. int X;
    8. int Y;
    9. int Z;
    10. } ;
    11. protected:
    12. private:
    13. };
    To copy to clipboard, switch view to plain text mode 

    is there any advantage using the old struct vs. the class inside a class style?

    i want to still scope the class/struc t_A like below at the end of the day.

    Qt Code:
    1. B::t_A param;
    To copy to clipboard, switch view to plain text mode 

    baray98

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: class in the class

    There's no difference between a class and a struct. And a struct is not 'old' at all (nor deprecated in some way). So I see no problems here

  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: class in the class

    There is a (small) difference: all stuff in a class is private by default, in a struct it's public.

Similar Threads

  1. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  2. How to use Signal through direct connection
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2007, 07:07
  3. Creating object of other class in Run() method
    By santosh.kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 15:05
  4. Replies: 2
    Last Post: 16th March 2007, 09:04
  5. 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.