473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Suggested technique for 'overloading' an inherited property

I have create a base class for a user control as well as a related base
class for its logic (nonvisual). As part of the non-visual class I have a
variable that references the base user object and a property to set it.

class VisualBase : ...Control { ... }

class LogicBase
{
private VisualBase _vObj;
public VisualBase VObj {get;set;}
}

Now I then went and inherited from both and created much more advanced
objects (VisualChild and LogicChild). I need a reference to the VisualChild
in the LogicChild but I wasn't sure the best way to code it. Do I just
rename the original or should I just change the property type. The question
then is in the other methods of the base/child logic class should I be using
the private _vObj or the public VObj property?

Should it be:

class LogicChild : LogicBase
{
public VisualChild VObj
{ get { return (VisualChild) _vObj;}
{ set { _vObj = (VisualBase)Value;}
}

or do I just add a new private variable of type VisualChild?

I've tried a few things and the compiler seems to let me get away with it so
I would appreciate any help.

thanks kindly,

jack
Nov 16 '05 #1
1 1371
the should be part should say:

public 'new' VisualChild VObj so it can replace the name...

"Jack Addington" <ja********@shaw.ca> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl...
I have create a base class for a user control as well as a related base
class for its logic (nonvisual). As part of the non-visual class I have a
variable that references the base user object and a property to set it.

class VisualBase : ...Control { ... }

class LogicBase
{
private VisualBase _vObj;
public VisualBase VObj {get;set;}
}

Now I then went and inherited from both and created much more advanced
objects (VisualChild and LogicChild). I need a reference to the
VisualChild in the LogicChild but I wasn't sure the best way to code it.
Do I just rename the original or should I just change the property type.
The question then is in the other methods of the base/child logic class
should I be using the private _vObj or the public VObj property?

Should it be:

class LogicChild : LogicBase
{
public VisualChild VObj
{ get { return (VisualChild) _vObj;}
{ set { _vObj = (VisualBase)Value;}
}

or do I just add a new private variable of type VisualChild?

I've tried a few things and the compiler seems to let me get away with it
so I would appreciate any help.

thanks kindly,

jack

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Earl Teigrob | last post by:
Is there a way to rename the public properties of a inherited class? I am inheriting an asp.net control (class) and am adding addtional functionality. (in this case, up to 3 borders on an...
4
by: Shayne H | last post by:
I have a query about an intricacy of inheritance and overloading. I am coding a class inherited from System.Uri. If I look in the object browser (with hidden members shown) there are 4 overloaded...
2
by: chetsjunk | last post by:
I am having problems with an inherited class not handling an event for the class it is inherited from. But it's not constistent, so I'm guessing the problem is elsewhere in my code. I created the...
6
by: Massimo Soricetti | last post by:
Hello, recently I wrote a little class which has to wrap two different type of data, showing the same external interface. I used operator overloading, but the same result I could eventually...
4
by: asad.naeem | last post by:
hi to all this is the problem about inheritence. I have designed a form with some essential controls which are required for every form which will inherited from it. for example i have Button1 on...
3
by: Chameleon | last post by:
What is better if you want upcasting in intermediate classes like below? Multiple Inheritance and Overloading or simply RTTI? RTTI wants time but MI and Overloading create big objects (because of...
3
by: Noodle | last post by:
Hi Guys, not sure if anyone can help me on this one but...... I have a class that I overload the equality operator (=). I also have a class that inherits from this first class which has extra...
8
by: yashwant pinge | last post by:
#include<iostream> using namespace std; class base { public: void display() { } };
10
by: Matthew | last post by:
Am I correct in thinking there is no method/function overloading of any kind in any version of PHP? Thanks, Matthew
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.