> If ID is protected in the base then it should be
> accessable in the derived.
yes. but not in constructor initialiser list
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/
>