473,396 Members | 1,755 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.

how to handle groups of objects

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! =-----
Jul 22 '05 #1
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
Jul 22 '05 #2
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! =-----
Jul 22 '05 #3
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?

Jul 22 '05 #4
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.

Jul 22 '05 #5
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.
Jul 22 '05 #6
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!
Jul 22 '05 #7

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

Similar topics

1
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...
14
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...
1
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...
4
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...
1
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...
10
by: Jeff Williams | last post by:
How can I get a list of the Groups both Local and Domain groups a User belongs to.
2
weaknessforcats
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...
7
by: Shraddha | last post by:
What is exactly a handle to an object????Is it same as reference....
3
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...
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
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: 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...
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
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
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
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.