Re: Questions of Designs

From: Universe (no email)
Date: 09/10/04


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!


Relevant Pages

  • Re: Questions of Designs
    ... This is crude way of declaring complete abstract behavior using language specific syntax. ...
    (comp.object)
  • Re: intel compiler and [REFERENCE] keyword?
    ... would not change by declaring the argument to be a character array as ... of the interface, ... compile, but have a trailing underscore on the exported function. ... the Fortran 2003 features of C interoperability or intrinsic modules. ...
    (comp.lang.fortran)
  • Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
    ... public static extern uint WMCreateEditor( ... public interface IWMMetadataEditor ... public interface IWMHeaderInfo3 ... This is definitely your problem--when declaring COM interfaces ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
    ... public static extern uint WMCreateEditor( ... public interface IWMMetadataEditor ... public interface IWMHeaderInfo3 ... This is definitely your problem--when declaring COM interfaces ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Questions of Designs
    ... But one must write "interface" and follow a specific form to create ... This is crude way of declaring complete abstract behavior using language specific syntax. ...
    (comp.object)