--- Indika Bandara <[EMAIL PROTECTED]> wrote:
> > If ID is protected in the base then it should be
> > accessable in the derived.
>
> yes. but not in constructor initialiser list
>
so, why does it have to be done in the initializer
list? It only needs to be done in the initializer
list if it is a const.
Ray
> class Base
> {
> Base(){}
> protected:
> int id;
> }
> class Derived
> {
>
> Derived()
> : id(1) // compile error
> {
> // of course in here all protected vars are
> available
> id = 1; // valid
> }
>
> };
>
> --- In [email protected], Ray Devore
> <[EMAIL PROTECTED]> wrote:
> >
> >
> > --- Indika Bandara <[EMAIL PROTECTED]> wrote:
> >
> > > consider following
> > > class Base
> > > {
> > > protected:
> > > int ID;
> > > }
> > > class Derived : public Base;
> > >
> > >
> > >
> > > what i want is when somebody inherits base he
> has to
> > > set 'ID' to a
> > > specific value. This should be guarenteed
> whenever
> > > somebody inherits
> > > Base.Methods i can think of is
> > > - ID is a reference. so it should be initialized
> in
> > > constructor, but
> > > the problem is in Derived the constructor
> > > initializer list doesn't
> > > have access to protected member ID??
> > > how can this be accomplished?
> > >
> > >
> > If ID is protected in the base then it should be
> > accessable in the derived.
> >
> > Ray
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Pinpoint customers who are looking for what you
> sell.
> > http://searchmarketing.yahoo.com/
> >
>
>
>
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the
tools to get online.
http://smallbusiness.yahoo.com/webhosting