bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help for cpp code


From: David Sugar
Subject: Re: help for cpp code
Date: Tue, 23 Dec 2003 16:39:59 -0500
User-agent: KMail/1.5.3

Do you think we should have a channel on freenode?  Do you think if we do 
people will actually come?

On Tuesday 23 December 2003 03:30 pm, Marc Boris Dürner wrote:
> On Tuesday 23 December 2003 13:35, Dheerendra Kulkarni wrote:
> > Please help me in what this code means
> >
> > NRLOLSR::NRLOLSR(nsaddr_t id) : Agent(PT_NRLOLSR),htimer(this),
> > ttimer(this) {
> > ...
> > ..
> > ..
> > ..
> >
> > };
> >
> > This is actually a constructor for a class called NRLOLSR now I don't
> > Understand what does literals following ':' mean (will they call
> > functions
> >
> > which are given there or what)
> > Dheerendra Kulkarni
>
> There should really be a CommonC++ channel on IRC  :) Also try #c++ on
> irc.freenode.net for questions like this in the future.
>
> I is called the initialiser-list. The items in that list are initialised
> before the constructor is
> called. The initialiser list is used to:
>
> - pass parameters to the constructor of a base class
> - initialise member variables
>
> Take the following example:
>
> //
> // A simple class A with a int as a private member.
> // Here the initialiser list is used to set the private member
> // to what is passed in to the consructor
> //
> class A {
>    public:
>    A(int i) : _number(i) {}
>    ~A() {}
>    private:
>    int _number;
> };
>
> //
> // A simple class B also with a private member. Here
> // the initialiser list is used to call the constructor of the
> // base class A and to set the member _ othernumber to 5
> //
> class B : public A {
>    public:
>    B() : A(3), _othernumber(5) {}
>    ~B() {}
>    private:
>    int _othernumber;
> };
>
>
> regards,
> Marc





reply via email to

[Prev in Thread] Current Thread [Next in Thread]