vector objects;
As for garbage collection/mem deallocation, the vector object handles that automatically in its destructor..
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
vector objects;
As for garbage collection/mem deallocation, the vector object handles that automatically in its destructor..
The STL is the "Standard TEMPLATE Library" so you need to use C++ TEMPLATE syntax to instantiate it. In the case of the STL containers, to declare a container write something like:
containerClass<dataType> variable name;
such as:
list<string> students;
vecotr<int> grades;
for your specific case here's come help:
// object.h
class Object
{
static vector<WHAT_TYPE_ARE_THE_OBJECTS> instantiatedObjects;
...
public:
...
};
// object.cpp
vector<WHAT_TYPE_ARE_THE_OBJECTS> Object::instantiatedObjects;
I suspect that you are meaning to replace WHAT_TYPE_ARE_THE_OBJECTS with Object* but I wasn't sure.
Also, realize that if you are going to do this, you are quite likely going to want to add some class level functions to instantiate objects, using one of the creation patterns described in the book "Design Patterns" (by Gamma, Helm, Johnson, Vlissides).
[This message has been edited by Myopic Rhino (edited October 19, 1999).]
vector<type> instanstiatedClasses;
------------------
LoungePig
OpenGUI
[This message has been edited by joeG (edited October 19, 1999).]
Problem: the program is not able to exit without crashing. I'm very sure that it occurs after the last bit of source code.
Here's the code inside the class declaration:
class Object
{
...
static vector instantiatedObjects;
...
};
Here's the code outside the class declaration:
vector Object::instantiatedObjects =
vector();
That'all the relative stuff to my problem.
Any suggestions?
See if you can duplicate the crash with a simple class (i.e., one member variable). If you can't, keep adding stuff to the simple class until it either looks like your original class (congrats!) or the vector blows up.
Mason McCuskey
Spin Studios
www.spin-studios.com