Re: Questions of Designs
From: Universe (no email)
Date: 09/10/04
- Next message: Cristiano Sadun: "Re: Static vs. Dynamic typing"
- Previous message: Universe: "Re: dip Notions 2 Major Errors"
- In reply to: Shashank: "Re: Questions of Designs"
- Next in thread: Shashank: "Re: Questions of Designs"
- Reply: Shashank: "Re: Questions of Designs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 10 Sep 2004 05:27:51 -0400
Shashank <shashank@icmgworld.com> wrote:
> Universe wrote:
> > Shashank <shashank@icmgworld.com> wrote:
> > > Universe wrote:
> > > >
> > > > ... A C++ ABC - abstract base class - has *nada*
> > > > implementation--only method declaration like a Java interface.
> > > Is it forced that a C++ abstract class cannot have implementation or we need to force that by
> > > using specific syntax?
> > A C++ ABC is where all methods are declared as "pure virtual".
> >
> > class ABC {
> > public:
> > virtual int doThis(ptr2someClass*)=0; // '=0' makes 'pure'
> > virtual char doThat(char)=0;
> > }
> >
> > class ConcreteDerived : public ABC {
> > public:
> > virtual doThis(ptr2someClass* SomeClass)
> > { // method concretely implemented };
> > virtual doThat(char aChar)
> > { // method concretely implemented };
> > };
> This is what, I was referring to, we still need to write class, where we make all functions pure
> virtual. This is crude way of declaring complete abstract behavior using language specific syntax.
>
> But if I say interface it guarantees abstract behavior. Which is cleaner and away from
> implementation strategy.
What's so different about the C++ ABC above and this Java interface:
public interface AnInterface {
public void setColor(Color c);
public void setPosition(double x,double y);
public void draw(DrawWindow dw);
}
Plus data members declared in a C++ ABC may be of *any* type and not
*limited* to be constants - static & final - as with Java interface
declarations.
Though in general one should avoid declaring data members in base
classes.
Elliott
-- Theory Leads, Practice Verifies Profiteer US Out of Iraq Now!
- Next message: Cristiano Sadun: "Re: Static vs. Dynamic typing"
- Previous message: Universe: "Re: dip Notions 2 Major Errors"
- In reply to: Shashank: "Re: Questions of Designs"
- Next in thread: Shashank: "Re: Questions of Designs"
- Reply: Shashank: "Re: Questions of Designs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|