Should 'public virtual' always become 'private virtual'? & using private inheritance
From: qazmlp (qazmlp1209_at_rediffmail.com)
Date: 01/31/04
- Next message: Peter Koch Larsen: "Re: Should 'public virtual' always become 'private virtual'? & using private inheritance"
- Previous message: EventHelix.com: "Re: Size of a struct - totally confused"
- Next in thread: Peter Koch Larsen: "Re: Should 'public virtual' always become 'private virtual'? & using private inheritance"
- Reply: Peter Koch Larsen: "Re: Should 'public virtual' always become 'private virtual'? & using private inheritance"
- Reply: Nick Hounsome: "Re: Should 'public virtual' always become 'private virtual'? & using private inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Jan 2004 07:08:44 -0800
class base
{
// other members
public:
virtual ~base()
{
}
virtual void virtualMethod1()=0 ;
virtual void virtualMethod2()=0 ;
virtual void virtualMethod3()=0 ;
} ;
I derive a class from base. I want to make all the virtual functions
as private.
class derived : public base
{
// other members
public:
virtual ~derived()
{
}
void myPublicInterface1() ;
void myPublicInterface1() ;
private:
virtual void virtualMethod1()=0 ;
virtual void virtualMethod2()=0 ;
virtual void virtualMethod3()=0 ;
} ;
I did the above considering the facts that
- in any case, the virtual functions will always be called through
the base class pointer only
- No. of public virtual interfaces should be reduced as much as
possible
Here are my questions:
1)
Can I consider this as a good design? If yes/no, why?
2)
How about
class derived : private base
{
}
instead of the above design, as anyway, all the inherited virtual
functions need to be made as private ?
Is this a correct design? If yes/no, why?
3)
What are the flaws in the above design and what do you suggest for
improvements?
- Next message: Peter Koch Larsen: "Re: Should 'public virtual' always become 'private virtual'? & using private inheritance"
- Previous message: EventHelix.com: "Re: Size of a struct - totally confused"
- Next in thread: Peter Koch Larsen: "Re: Should 'public virtual' always become 'private virtual'? & using private inheritance"
- Reply: Peter Koch Larsen: "Re: Should 'public virtual' always become 'private virtual'? & using private inheritance"
- Reply: Nick Hounsome: "Re: Should 'public virtual' always become 'private virtual'? & using private inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|