473,473 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Pattern for this? Or something?

Supposing I have two classes:

class UIControl1 : public BaseControl1 {}

class UIControl2 : public BaseControl2 {}

where both base classes are not related between them.
Then I'd like to -depending the user preference- use one of
those controls. That is, I have to do this at runtime, depending
on some flag set by the user of the program. Is there any way
to relate these two classes? If they derived from the same (or
related) base, then I would easily use that base class pointer,
without worrying which class I'm using. But in this case, what
can I do?

TIA
Jul 22 '05 #1
1 1005
"notme" <a@b.c> wrote in message news:2v*************@uni-berlin.de...
Supposing I have two classes:

class UIControl1 : public BaseControl1 {}

class UIControl2 : public BaseControl2 {}

where both base classes are not related between them.
Then I'd like to -depending the user preference- use one of
those controls. That is, I have to do this at runtime, depending
on some flag set by the user of the program. Is there any way
to relate these two classes? If they derived from the same (or
related) base, then I would easily use that base class pointer,
without worrying which class I'm using. But in this case, what
can I do?


You can write your own proxy classes, e.g.,
class UIControl1Proxy : public BaseControlProxy
{
UIControl1 mUIControl1;
...
};

class UIControl2Proxy : public BaseControlProxy
{
UIControl2 mUIControl2;
...
};

Add a polymorphic public interface to BaseControlProxy and override it in
each of the derived classes, and at runtime choose which derived class to
use.

DW

Jul 22 '05 #2

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

Similar topics

8
by: gsv2com | last post by:
One of my weaknesses has always been pattern matching. Something I definitely need to study up on and maybe you guys can give me a pointer here. I'm looking to remove all of this code and just...
4
by: shonend | last post by:
I am trying to extract the pattern like this : "SUB: some text LOT: one-word" Described, "SUB" and "LOT" are key words; I want those words, everything in between and one word following the...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
1
by: halekio | last post by:
Hi all, Please bear with me as I've only started programming in C# 2 weeks ago and this is my first contact with OOP. I ran into a situation where I needed to catch an event in an object that...
1
by: halekio | last post by:
Hi all, Please bear with me as I've only started programming in C# 2 weeks ago and this is my first contact with OOP. I ran into a situation where I needed to catch an event in an object that...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.