How do I override a class's properties?

G

Guest

Hi!
I want to make a base class with some base properties and then derive
different other classes from that in which I want to override the base
properties to get specialized behaviour unique for each derived class as
follows:

MyBaseClass {PropertyA…}
MyDerivedClassA: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassB: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassC: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)

Suppose that PropertyA is a form, on which I want to put different kinds or
numbers of controls in each class.

Is this possible to do? Which techniques are to be used?

Regards,
M Shafaat
 
M

Mythran

M Shafaat said:
Hi!
I want to make a base class with some base properties and then derive
different other classes from that in which I want to override the base
properties to get specialized behaviour unique for each derived class as
follows:

MyBaseClass {PropertyA…}
MyDerivedClassA: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassB: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)
MyDerivedClassC: MyBaseClass {PropertyA //with unique, extended
functionality, different from that of other classes)

Suppose that PropertyA is a form, on which I want to put different kinds
or
numbers of controls in each class.

Is this possible to do? Which techniques are to be used?

Regards,
M Shafaat

If you base class is never created and always inherited...and all of it's
property and methods are always overridden, then why not make the base class
an Interface?

Mythran
 
J

jabits

An interface can not contain any implementation (i.e. code). If the
base class is not (and should not) ever be instantiated, it can be
marked 'abstract' which means it must always be inherited from.
thanks, jabits
 
G

Guest

What I want to do is to reference and treat my inherited classes as the
BaseClass, like this:

for each MyBaseClass MyClass in MyCollection
{ MyClass.DataForm.show() }
…

MyCollection here above may keep all types of inherited classes from
MyBaseClass.

I want to treat all the inherited classes in one single line of code in
stead of using hard coding like:

case MyClass
MyDerivedClassA:
{…}
MyDerivedClassB:
{…}
…

Regards
M Shafaat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top