This is a little long, sorry.
Let's say I have a class
class TMyClass
{
void funca();
void funcb();
};
and then I have objects
TMyClass* A = new TMyClass;
TMyClass* B = new TMyClass;
TMyClass* C = new TMyClass;
Sometimes, I need to call all three objects funca, like this :
A->funca();
B->funca();
C->funca();
So finally to the question - is there a way to combine these objects in a
"Meta" object that could do
something like this :
TMyClass* Meta=new TMyClass;
Meta->funca();
and have it run A, B, and C objects funca called?
THanks, Brian Dumas
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =----- 6 1219
"Brian Dumas" <br***@kvdco.com> wrote in message
news:40********@corp.newsgroups.com... This is a little long, sorry. Let's say I have a class
class TMyClass { void funca(); void funcb(); };
and then I have objects
TMyClass* A = new TMyClass; TMyClass* B = new TMyClass; TMyClass* C = new TMyClass;
Sometimes, I need to call all three objects funca, like this :
A->funca(); B->funca(); C->funca();
So finally to the question - is there a way to combine these objects in a "Meta" object that could do something like this : TMyClass* Meta=new TMyClass; Meta->funca();
and have it run A, B, and C objects funca called?
THanks, Brian Dumas
Well, you could put them inside another class, and have a function in THAT
class which calls all three objects' function. But that doesn't save any
lines of code, unless you're making these same three calls in multiple
places.
Another idea is to have the pointers in an array, and loop through the
array. Again, that doesn't save much, unless you have more than just three
objects.
Perhaps you could tell us WHY you want to combine the calls? Writing three
lines of code is not that much work, after all.
-Howard
To explain it further, I have a class that has alot of functions, not just a
few. There might be up to 64 of the these objects in a users programs. In
some cases, they use the objects individually, but in some cases, they are
grouped together. So, for object 0, they might call function A with
parameter aaa, but they might call functiion a for objects 1,2,3,4 with
parameter bbb. In the case of object 0, it is one line. In the case of
objects 1,2,3,4, it is a total of 4 lines. And this all might be repeated
100 times in the users code. So, instead of these 4 lines everytime, it
would be great to group them into one object, and then just call that one
object 100 times. Anyway, I implemented it using STL and a duplicated the
function names in the primitive object to the grouped object, and they can
create grouped objects (even if it is just a group of 1). It just seems to
be alot of duplication.
Thanks, Brian
"Howard" <al*****@hotmail.com> wrote in message
news:c0********@dispatch.concentric.net... "Brian Dumas" <br***@kvdco.com> wrote in message news:40********@corp.newsgroups.com... This is a little long, sorry. Let's say I have a class
class TMyClass { void funca(); void funcb(); };
and then I have objects
TMyClass* A = new TMyClass; TMyClass* B = new TMyClass; TMyClass* C = new TMyClass;
Sometimes, I need to call all three objects funca, like this :
A->funca(); B->funca(); C->funca();
So finally to the question - is there a way to combine these objects in
a "Meta" object that could do something like this : TMyClass* Meta=new TMyClass; Meta->funca();
and have it run A, B, and C objects funca called?
THanks, Brian Dumas
Well, you could put them inside another class, and have a function in THAT class which calls all three objects' function. But that doesn't save any lines of code, unless you're making these same three calls in multiple places.
Another idea is to have the pointers in an array, and loop through the array. Again, that doesn't save much, unless you have more than just
three objects.
Perhaps you could tell us WHY you want to combine the calls? Writing
three lines of code is not that much work, after all.
-Howard
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Brian Dumas wrote: To explain it further, I have a class that has alot of functions, not just a few. There might be up to 64 of the these objects in a users programs. In some cases, they use the objects individually, but in some cases, they are grouped together. So, for object 0, they might call function A with parameter aaa, but they might call functiion a for objects 1,2,3,4 with parameter bbb. In the case of object 0, it is one line. In the case of objects 1,2,3,4, it is a total of 4 lines. And this all might be repeated 100 times in the users code. So, instead of these 4 lines everytime, it would be great to group them into one object, and then just call that one object 100 times. Anyway, I implemented it using STL and a duplicated the function names in the primitive object to the grouped object, and they can create grouped objects (even if it is just a group of 1). It just seems to be alot of duplication.
Indeed it does seem like a lot of code.
If they are grouped together why not put them into a
container and apply a functor to the objects in the container?
Brian Dumas wrote: This is a little long, sorry. Let's say I have a class
class TMyClass { void funca(); void funcb(); };
and then I have objects
TMyClass* A = new TMyClass; TMyClass* B = new TMyClass; TMyClass* C = new TMyClass;
Sometimes, I need to call all three objects funca, like this :
A->funca(); B->funca(); C->funca();
So finally to the question - is there a way to combine these objects in a "Meta" object that could do something like this : TMyClass* Meta=new TMyClass; Meta->funca();
and have it run A, B, and C objects funca called?
THanks, Brian Dumas
Check out std::for_each, in the <algorithms> header. Check out std::for_each, in the <algorithms> header.
ofcourse you meant <algorithm> without an 's' ;-)
Pointing it out just in case OP doesn't know of the correct header name.
Sharad Kala wrote: Check out std::for_each, in the <algorithms> header.
ofcourse you meant <algorithm> without an 's' ;-) Pointing it out just in case OP doesn't know of the correct header name.
Right you are! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Craig Ringer |
last post by:
Hi folks
I'm a bit of a newbie here, though I've tried to appropriately research
this issue before posting. I've found a lot of questions, a few answers
that don't really answer quite what I'm...
|
by: Howard |
last post by:
Hi,
I recently had a problem where I decided to store objects in a vector.
(Previously, I had always stored pointers in vectors). Well, naturally,
when storing an object in a vector, using...
|
by: Ron Adam |
last post by:
I was trying to see if I can implement property groups so I can set and
pass arguemts as dictionaries. I think this will simplify interfacing
to multiple objects and funtions that use a lot of...
|
by: James |
last post by:
I have a VB windows forms application that accesses a Microsoft Access
database that has been secured using user-level security. The
application is being deployed using No-Touch deployment. The...
|
by: j.eckles |
last post by:
I'm trying to determine if there is a way in VBScript, perhaps via ADO
or DAO, to access what I'll term MS Access "object groups". What I
mean by "object groups" are the folders that you see under...
|
by: Jeff Williams |
last post by:
How can I get a list of the Groups both Local and Domain groups a User
belongs to.
|
by: weaknessforcats |
last post by:
Handle Classes
Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the...
|
by: Shraddha |
last post by:
What is exactly a handle to an object????Is it same as reference....
|
by: Roobmeister |
last post by:
I have a shared Access database that somehow got its Pivot Table Viewer corrupted - none of the queries could be converted to Pivot Table view.
Since I got nowhere with "Compact and Repair", I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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,...
|
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...
|
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,...
| |