Re: Adding member property to abstract class

From: C.E.O. Gargantua (usb_at_cord.blah)
Date: 01/20/05


Date: Thu, 20 Jan 2005 15:00:54 -0800


Ok, just ignore me.

The answer is "yes, of course".

I just had the wrong syntax when I added the field ( I must have been
dead tired, I didn't add a datatype to it LOL of course it thew an
error, and because I'm new to abstract classes, I /assumed/ that they
were the problem !?! ).

CEO Gargantua wrote:
>
> The code that I'm working on isn't much difference from what I posted,
> because I hit a road block with trying to add a property to an abstract
> class...and that's the problem I am posting about.
>
> > The code that you've posted has various potential problems in - there
> > are no properties at all, you're trying to return void, and you're not
> > actually implementing the method in the interface.
>
> Well, the implementation is taken care of by the abstract class...that
> is, its methods act as defaults that handle the requirements of the
> interface. Then I can override them using polymorphism for individual
> classes that implement the abstract.
>
> Jon Skeet [C# MVP] wrote:
>
>> C.E.O. Gargantua <usb@cord.blah> wrote:
>>
>>> I want to have a member property that is common to a set of classes.
>>>
>>> I designed an abstract class, but when I try to add it to the
>>> abstract class, it flags an error in VS.NET.
>>>
>>> The design ( summarized is like this ) :
>>>
>>>
>>> interface interfaceA {
>>> string myMeth();
>>> }
>>>
>>> public class abstract ClassA{
>>>
>>>
>>> // string _myStrValue; // This is what I want to add, but
>>> // the syntax doesn't fit...why?
>>>
>>> string myMethod()
>>> {
>>> return void;
>>> }
>>> }
>>>
>>> public class myDerivedClassA : ClassA, interfaceA
>>>
>>> {
>>>
>>>
>>> }
>>
>>
>>
>> Could you post a short but complete program which demonstrates the
>> problem?
>>
>> See http://www.pobox.com/~skeet/csharp/complete.html for details of
>> what I mean by that.
>>
>
>>
>
>

-- 
Texeme
http://texeme.com
incognito () Updated Almost Daily
http://kentpsychedelic.blogspot.com


Relevant Pages

  • Re: [PHP] What is the practical use of "abstract" and "interface"?
    ... If your code doesn't have an API and clear separation of parts, then neither abstract classes nor interfaces are useful to you. ... If you're not writing OOP code, then neither is of any use to you as both are OOP concepts. ... All component A needs to know about component B is that it implements interface Foo, meaning that you know, absolutely, that you can call $b->fooand get back a string and $b->barand get back a database connection, because the interface says so. ...
    (php.general)
  • Re: PHP5 Bug?? extended abstract type enforcement
    ... >> Abstract classes can never be instantiated, only implementations can. ... >> wrong interface, ... from which lists are derived. ...
    (comp.lang.php)
  • Re: Ensuring a method exists
    ... Pascal Costanza ha escrito: ... When different classes offer similar functionality and you want ... Interface types are more flexible than class types because the former ... which is an especification of abstract classes in C++. ...
    (comp.lang.lisp)
  • Re: Ensuring a method exists
    ... Pascal Costanza ha escrito: ... When different classes offer similar functionality and you want ... Interface types are more flexible than class types because the former ... which is an especification of abstract classes in C++. ...
    (comp.lang.lisp)
  • Re: Adding member property to abstract class
    ... because I hit a road block with trying to add a property to an abstract ... > actually implementing the method in the interface. ... its methods act as defaults that handle the requirements of the ...
    (microsoft.public.dotnet.languages.csharp)