Re: OOP 101 - Inheritance confusion

From: ilPostino (news_at_ip80.com)
Date: 03/19/04


Date: Fri, 19 Mar 2004 14:32:37 -0500

let me take my foot out my mouth -

correction to below: if you want to stop a class from being instantiated use
abstract! not inherited

"ilPostino" <news@ip80.com> wrote in message
news:OaAFwfeDEHA.2932@tk2msftngp13.phx.gbl...
> Stop thinking about Abstract and Interface in the same context. They are
> used for different things.
>
> If you want to stop a class from being inherited use an abstract class.
> Pretend you know nothing about interfaces and never
> use that keyword again ;)
>
> -ilPostino
>
>
>
> "TomB" <shuckle@hotmailXXX.com> wrote in message
> news:OPCJA3cDEHA.2628@TK2MSFTNGP11.phx.gbl...
> > OK.
> > An interface has NO implementation code and everything MUST be
overriden.
> > Correct?
> > Whereas an abstract can have implementation code, can be overriden, and
> > can't be instantiated.
> >
> > Jeez, I thought I head around all this stuff.
> >
> > TomB
> >
> > "David Browne" <davidbaxterbrowne no potted meat@hotmail.com> wrote in
> > message news:e0WiKscDEHA.2932@tk2msftngp13.phx.gbl...
> > >
> > > "TomB" <shuckle@hotmailXXX.com> wrote in message
> > > news:uFObcncDEHA.1544@TK2MSFTNGP09.phx.gbl...
> > > > I'm sure this is OOP 101 but I'm confused.
> > > >
> > > > I'm writing a simple accounting type application. I created an
> abstract
> > > > class called IAccount, which my other account types are derived
from.
> > >
> > > IAccount would be an interface. You just want an abstract class.
> Abstract
> > > simply means that it cannot be instantiated directly.
> > >
> > > abstract class Account
> > > {
> > > protected Decimal balance;
> > > public Decimal Debit(Decimal Amount)
> > > {
> > > balance -= Amount;
> > > return balance;
> > > }
> > > }
> > >
> > > class DDAAccount : Account
> > > {
> > > protected string accountNumber;
> > > DDAAccount(string AccountNumber)
> > > {
> > > accountNumber = AccountNumber;
> > > balance = 0;
> > > }
> > > }
> > >
> > > David
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: OOP 101 - Inheritance confusion
    ... > let me take my foot out my mouth - ... > correction to below: if you want to stop a class from being instantiated ... >> Stop thinking about Abstract and Interface in the same context. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: e1000e regression (interface hang) with latest -git
    ... e1000e regression (interface hang) with latest -git ... I've got a Nehalem testbox that developed a new e1000e problem in this ... I started seeing this very early in the merge window, ... 6ea7ae1: e1000e: enable ECC correction on 82571 silicon ...
    (Linux-Kernel)
  • RE: e1000e regression (interface hang) with latest -git
    ... e1000e regression (interface hang) with latest -git ... I've got a Nehalem testbox that developed a new e1000e problem in this ... I started seeing this very early in the merge window, ... 6ea7ae1: e1000e: enable ECC correction on 82571 silicon ...
    (Linux-Kernel)
  • Re: Questions of Designs
    ... Interface definition should not have option to write implementation code. ... behaviour into the ABC and Java interfaces don't let you do that. ... class MyAbc ...
    (comp.object)
  • Re: WPA-TSK connection problem
    ... correction to configuration: ... no dot11 qos mode ... Radio interface. ... This is apparently a known issue with PDA's and Cisco Access Points. ...
    (microsoft.public.pocketpc.wireless)