473,406 Members | 2,705 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,406 software developers and data experts.

list of template class objects

i have a template class definition.

Expand|Select|Wrap|Line Numbers
  1. template <class T> 
  2. class ab
  3.    ...
  4. };
  5.  
how do i declare a list of type ab using STL's list container.
Apr 19 '08 #1
2 1386
Laharl
849 Expert 512MB
You use list<ab<T> >. You have to leave the space between the >, otherwise the compiler misinterprets it as the >> operator...
Apr 19 '08 #2
thanks, it works.
another problem, i'm not able to declare an iterator in the same way.

Expand|Select|Wrap|Line Numbers
  1. std::list<MyClass<T> >::iterator i;
  2.  
gives an error: "expected ';' before i".
Apr 19 '08 #3

Sign in to post your reply or Sign up for a free account.

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: Johan | last post by:
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> *>...
4
by: cass | last post by:
Both class A and B inherites from class C. A std::list is used to contain a list of objects of class A or a list of objects of class B, but not both types of classes at the same time. How to...
9
by: Marcin Kalicinski | last post by:
Hi everybody, I am creating an intrusive list ('next' and 'prev' pointers are stored within an object that is in a list). One method of doing that is to inherit all objects from some class that...
4
by: Piotr Sawuk | last post by:
First off, thanks for the help, this group was a great support for my efforts of learning c++. However, yet again I plan to throw away what I programmed and re-use a little more of what stl has to...
8
by: Tony Johansson | last post by:
Hello Experts! What does this mean actually. If you have a template with a type and non-type template argument, say, like this template<typename T, int a> class Array {. . .}; then A<int,...
9
by: alopatenko | last post by:
I have a template class template <Class W> class WS At some point I have to use a STL list WS<W>objects so, I define #include <list>
5
by: cmk128 | last post by:
Hi All Is there any alternative way to let parent class hold a vector of its child class's objects? I meant when i create an object from the child class, in the parent class, i am able to...
4
by: colin | last post by:
Hi, Im trying to implement a generic list class for a number of 3d object types, that form a 3d solid model, take the easiest one Point for example, it contains a Vector3 and a list of other...
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
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
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...
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,...
0
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...

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.