Re: What is going on here?

From: Karl Heinz Buchegger (kbuchegg_at_gascad.at)
Date: 08/18/04

  • Next message: Alwyn: "Re: What is going on here?"
    Date: Wed, 18 Aug 2004 13:47:46 +0200
    
    

    rs wrote:
    >
    > I am trying to figure out what is going on with the constructor in the
    > following class.
    > What I can not figure out is why is there a colon and then the base class
    > declaration in the constructor function.

    Everything after the ':' up to the opening '{' is called the 'intializer
    list'. Its use is to specify to the compiler what initializations should
    occour. This can be: initializations of member variables or the initialization
    of the base class this class is derived from.

    >
    > Why is there a semicolon after the inline definition { m_pMainWnd = NULL; }
    > ;
    It's just syntactic sugar. It doesn't need to be there, but it isn't
    wrong either. As for the same reason as there is no error in

    // Look Ma. Lots of empty statements

    ;

    int main()
    {
      ;
      ;
      ;
    }

    -- 
    Karl Heinz Buchegger
    kbuchegg@gascad.at
    

  • Next message: Alwyn: "Re: What is going on here?"

    Relevant Pages

    • Re: What is going on here?
      ... >>declaration in the constructor function. ... Its use is to specify to the compiler what initializations should ... initializations of member variables or the initialization ... an empty declaration. ...
      (alt.comp.lang.learn.c-cpp)
    • Re: slab quirks in DEBUG, ctor, and initialization
      ... for each successful allocation. ... cache is grown (see cache_grow calling cache_init_objs) which is the ... that your constructor is used only for newly allocated ... of it, and were the initializations performed into allocated space), ...
      (Linux-Kernel)
    • Re: Not Initializing Variables : Performance impact
      ... value you are setting - they lead to code bloat. ... write them into every constructor in your class (so 3x3 ... initializations in this case). ... significant performance issue? ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: C++ design question
      ... > to see if anyone can recommend a design improvement. ... Move both initializations inside the ellipses so ... Why not invoke the barDerived constructor? ... my_bar_derived is private so there is no issue of ...
      (comp.object)
    • Re: Create objects using dynamic class names
      ... classes from a common base class and have an array of class references ... Not necessarily an open array, although that neatly coalesces the steps ... The constructor of the base class can only construct an instance of the ... TPageClass = class of TPage; ...
      (comp.lang.pascal.delphi.misc)