473,387 Members | 1,464 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,387 software developers and data experts.

list with different class objects

Hi,

How to create a list with template classes. I want to do something like this

template<class T>class Callback
{
// rest of class
};

typedef list< template<class T>Callback<T> *> CallbackList;

Later
class A
{
public :
void addCallback( ????? );
// rest of class
CallbackList cl;
};

void A :: addCallback( ???? )
{
cl.push_back< ????? >
}

How to add diffenrent class object to the linked list and what to change for
????

thanks

Johan
Jul 22 '05 #1
1 1574
"Johan" <me@knoware.nl> wrote...
How to create a list with template classes. I want to do something like this
template<class T>class Callback
{
// rest of class
};

typedef list< template<class T>Callback<T> *> CallbackList;
There is no template typedefs. You can only have a typedef of
a particular class/type. You need 'T' defined here.

Later
class A
{
public :
void addCallback( ????? );
// rest of class
CallbackList cl;
You cannot have an object of an incomplete type (even if you
could have template typedefs). You would still need to define
the "T" in your 'CallbackList'.
};

void A :: addCallback( ???? )
{
cl.push_back< ????? >
}

How to add diffenrent class object to the linked list and what to change for ????


Look up "heterogeneous containers" on Google. And if you don't see
it, the very first question you need to ask yourself is "why am I
putting those _unrelated_ objects in the same container?" Perhaps
it will give you the idea to make them related somehow...

V
Jul 22 '05 #2

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

Similar topics

6
by: alg | last post by:
Is it possible to put different types of objects in a single STL list? If not what STL template should be used which will contains various objects of different types? Thanks for your help!
1
by: Glen Able | last post by:
Hi, I have a collection of lists, something like this: std::list<Obj*> lists; Now I add an Obj to one of the lists: Obj* gary; lists.push_front(gary);
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
5
by: Little | last post by:
I have this program and I need to work on the test portion, which tests if a Val is in the list. It returns false no matter what could you look at the part and see what might need to be done to fix...
6
by: Osiris | last post by:
Is the following intuitively feasible in Python: I have an array (I come from C) of identical objects, called sections. These sections have some feature, say a length, measured in mm, which is...
6
by: Amit Bhatia | last post by:
Hi, I am not sure if this belongs to this group. Anyway, my question is as follows: I have a list (STL list) whose elements are pairs of integers (STL pairs, say objects of class T). When I create...
5
by: David Longnecker | last post by:
I'm working to create a base framework for our organization for web and client-side applications. The framework interfaces with several of our systems and provides the business and data layer...
40
by: nufuhsus | last post by:
Hello all, First let me appologise if this has been answered but I could not find an acurate answer to this interesting problem. If the following is true: C:\Python25\rg.py>python Python...
10
by: lpinho | last post by:
Hi all, I have a class (named for the example myObject) that can be of several types (int, string, float, etc), instead of using a object to define it's type I used a generic. public class...
11
by: Scott Stark | last post by:
Hello, The code below represents a singly-linked list that accepts any type of object. You can see I'm represting the Data variable a System.Object. How would I update this code to use...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
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
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 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.