Re: Is this proper in OO theory?

From: Marina (someone_at_nospam.com)
Date: 07/07/04


Date: Wed, 7 Jul 2004 11:25:40 -0400

I don't feel like I'm getting a clear example of the issue from this
particular code sample.

In general, there is nothing wrong with putting anything in the base class
that will be useful to all its children, even if it requires some
parameters.

"Daniel Billingsley" <dbillingsley@NO_durcon_SPAAMM.com> wrote in message
news:uKwNqTDZEHA.2972@TK2MSFTNGP12.phx.gbl...
> The base class obviously can't know anything about a class which inherits
> from it, but is it acceptable to have a base class method which will be
> given information from an inherited class?
>
> For (a stupid) example:
>
> -----------
>
> public abstract class BaseClass
> {
> private int _someInteger=0;
>
> protected int AddNumbers(int anotherNumber)
> {
> return anotherNumber + _someInteger;
> }
>
> }
>
> public class Class2 : BaseClass
> {
> private int _anotherInteger;
> public int GetANumber()
> {
> return base.AddNumber(_anotherInteger);
> }
> }
>
> ----------
>
> The underlying issue is that the generic code in the AddNumbers method
from
> example is known to be needed in all the classes inheriting from
BaseClass,
> but needs some additional information based on the specifics of the
> inherited class (it's a data access method in reality).
>
>



Relevant Pages

  • Re: inheritance not working properly -- Help please!!
    ... I'll post the base class and the inherited class (definition and 1 ... PlayerInfos: CPlayerInfos, new ... public override // that's where it should pop with the Connectmethod, ... should pop with my base class methods... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Cannot Access Base Members when Inheriting WebControl
    ... my first thought is that your base class must reside in the App_Code sub ... class members from my inherited class. ... I create a base .ascx control and add a method. ... public partial class ResumeCapture_ResumeCaptureBase: myWebControlBase ...
    (microsoft.public.dotnet.framework.aspnet)
  • Real code coming shortly
    ... I know about the missing #includes... ... I have a base class and several classes inheriting from it that all have different implementations of the base class's virtual methods. ... If I use the base class pointer to call the overloaded methods in the inherited class, it calls the original methods in the base class instead. ... extension testExtension; ...
    (microsoft.public.vc.language)
  • Re: "Hiding" an inherited property?
    ... > class invisible to the programmer? ... For it to be possible to treat any inherited class instance as though it ... were a base class instance, the inherited class must have all of the members ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: static and base classes
    ... what are some different ways around the following violation: ... method of the derived class ... Could you show a small code sample of what you are trying to do. ... Unless the variable inside the base class is static as well this makes no ...
    (microsoft.public.dotnet.languages.csharp)