Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Omg! (http://www.programmingforums.org/showthread.php?t=12293)

rsnd Jan 1st, 2007 10:27 PM

Omg!
 
What is right with this piece of code!
:

class CustomizeDialog :
        public nContainerWindow
{
        nStatic LabelNick;
        nStatic LabelQutMessage;
        nEdit TextNick;
        nEdit TextQuitMessage;
        nTickBox CheckRecordNoIncChat;
        nTickBox CheckRecordAll;
        nStatic LabelRecording;
        nTickBox CheckRecNoIncUserInfo;
        nStatic LabelGameplay;
        nComboBox CmbGameMode;
        nButton ButtionDone;
        nButton ButtonAdvanced;

        class SW_SpecialLabel : public nStatic {
                void initialize();
        } SpecialLabel;

public:

        void on_initialize();

};


Indigno Jan 1st, 2007 10:45 PM

I'm assuming you mean what is wrong. And I think it's the semicolon at the very end after the parentheses. Unless I'm mistaken.

Game_Ender Jan 1st, 2007 11:11 PM

There is nothing wrong with that code at all. The following compiles fine with GCC 4.1 and all warnings cranked up.
:

  1. class nStatic {};
  2. class nContainerWindow {};
  3. class nEdit {};
  4. class nTickBox {};
  5. class nComboBox {};
  6. class nButton {};
  7.  
  8. class CustomizeDialog :
  9.         public nContainerWindow
  10. {
  11.         nStatic LabelNick;
  12.         nStatic LabelQutMessage;
  13.         nEdit TextNick;
  14.         nEdit TextQuitMessage;
  15.         nTickBox CheckRecordNoIncChat;
  16.         nTickBox CheckRecordAll;
  17.         nStatic LabelRecording;
  18.         nTickBox CheckRecNoIncUserInfo;
  19.         nStatic LabelGameplay;
  20.         nComboBox CmbGameMode;
  21.         nButton ButtionDone;
  22.         nButton ButtonAdvanced;
  23.  
  24.         class SW_SpecialLabel : public nStatic {
  25.                 void initialize();
  26.         } SpecialLabel;
  27.  
  28. public:
  29.  
  30.         void on_initialize();
  31.  
  32. };
  33.  
  34. int main(void)
  35. {
  36.     return 0;
  37. }


DaWei Jan 1st, 2007 11:32 PM

The problem is with your post, rsnd; it's shitty. Use a meaningful subject line. Show enough definitions that someone can assess your code. As you see, GameEnder made some assumptions, added some definitions, and got the code to compile. Give the content of your error messages. Indicate what line or statement triggered them.

At 117 posts, and having read the rules and a "How to Post a Question" thread (you have done that, right?), this just shows an infantile approach. This is not ProgrammingKindergarten.org.

rsnd Jan 1st, 2007 11:46 PM

DaWei is still mean to me =(

Dont you at least think that there is something wrong there with classes inside classes and function declarations =( I must be getting old

DaWei Jan 1st, 2007 11:49 PM

Hell, I don't cater to kids acting stupid, much less adults. If that's mean, go whine to mama.

If you meant to ask if classes can be nested, why didn't you just ask (or try a simple example out in your compiler).

Even if you've read the rules, I recommend you go to them again and click on that "Smart questions" link.

bl00dninja Jan 2nd, 2007 12:41 AM

yeah, you can nest classes...you can do all types of weird shit.

Jimbo Jan 2nd, 2007 7:02 AM

Quote:

Originally Posted by rsnd (Post 121990)
Dont you at least think that there is something wrong there with classes inside classes and function declarations =( I must be getting old

What is wrong with this? Scoping rules still apply, so it's just another facet to organizing your code structure.

Ravalon Jan 2nd, 2007 9:49 AM

Quote:

Dont you at least think that there is something wrong there with classes inside classes and function declarations =(
Why would there be? Nested classes make perfect sense because that is a valid organizational technique when the nested class is dependent on the enclosing class or function, or the scope of the nested class needs to be restricted to only the enclosing class or function.


All times are GMT -5. The time now is 1:20 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC