By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,696 Members | 1,486 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,696 IT Pros & Developers. It's quick & easy.

How do I override a class's properties?

P: n/a
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
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"M Shafaat" <MS******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
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

Nov 17 '05 #2

P: n/a
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

Nov 17 '05 #3

P: n/a
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
"Mythran" wrote:

"M Shafaat" <MS******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
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

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.