Y Ynog Golden Member Oct 9, 2002 1,782 1 0 Jun 4, 2004 #1 Its been a while since I have used C++ so I ask this question I need to create a dynamic array that contains pointers to classes. What is the best way to do this?
Its been a while since I have used C++ so I ask this question I need to create a dynamic array that contains pointers to classes. What is the best way to do this?
EagleKeeper Discussion Club Moderator<br>Elite Member Staff member Oct 30, 2000 42,589 5 0 Jun 4, 2004 #2 use the vector<class*,class*> name;
A Armitage Banned Feb 23, 2001 8,086 0 0 Jun 4, 2004 #3 Originally posted by: EagleKeeper use the vector<class*,class*> name; Click to expand... yep ... use the vector container from STL But shouldn't it just be vector<class*> hndl; Not sure what the second class* is for in yours?
Originally posted by: EagleKeeper use the vector<class*,class*> name; Click to expand... yep ... use the vector container from STL But shouldn't it just be vector<class*> hndl; Not sure what the second class* is for in yours?
B Barnaby W. Füi Elite Member Aug 14, 2001 12,343 0 0 Jun 4, 2004 #4 Yeah, the second template argument is the allocator. So definitely not vector<class *, class *> #include <vector> using namespace std; .... vector<class *> vec; vec.push_back(&one_instance); vec.push_back(&another_instance); http://www.sgi.com/tech/stl/Vector.html http://cppreference.com/cppvector.html
Yeah, the second template argument is the allocator. So definitely not vector<class *, class *> #include <vector> using namespace std; .... vector<class *> vec; vec.push_back(&one_instance); vec.push_back(&another_instance); http://www.sgi.com/tech/stl/Vector.html http://cppreference.com/cppvector.html