Results 1 to 4 of 4

Thread: static enum in a class

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default static enum in a class

    Hello,
    I need to write something like this below but this doens't compile:
    Qt Code:
    1. class D {
    2. public:
    3. D ( P::Type t1, P::Type t2) { }
    4. };
    5.  
    6. class P {
    7. public:
    8. static const enum Type { typea, typeb, typec };
    9. D d1;
    10. };
    To copy to clipboard, switch view to plain text mode 
    I think D doesn't know Type because it's declared before BUT I'd like keep Type inside some class...how change, please?
    Regards

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: static enum in a class

    Qt Code:
    1. class P;
    2. class D {
    3. public:
    4. D ( P::Type t1, P::Type t2) { }
    5. };
    6.  
    7. class P {
    8. public:
    9. enum Type { typea, typeb, typec };
    10. D d1;
    11. };
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: static enum in a class

    it doens't compile...
    Regards

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: static enum in a class

    Qt Code:
    1. class D;
    2. class P;
    3.  
    4. class P {
    5. public:
    6. enum Type { typea, typeb, typec };
    7. //D d;//D must be fully defined or use pointer
    8. //D *d;//this compiles fine
    9. };
    10.  
    11. class D {
    12. public:
    13. D(P::Type t1, P::Type t2) { }
    14. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 16
    Last Post: 23rd May 2008, 10:12
  2. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  3. Replies: 2
    Last Post: 16th March 2007, 09:04
  4. Accessing to a static variable from the same class
    By xgoan in forum General Programming
    Replies: 6
    Last Post: 5th March 2007, 10:50
  5. Is there the static class in C++?
    By gtthang in forum General Programming
    Replies: 4
    Last Post: 25th February 2006, 05:46

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.