im having a problem with a static deque inside of one of my classes. i know that you have to initialize static members of a class before you can use them but i cant figure out how to initialize a static deque inside of a template class. a little help please?
#include <iostream>
#include <deque>
using namespace std;
template <typename T>
class jar
{
public:
T * value;
static int jars;
static deque<jar*> jarlist;
template<typename S>
jar(S obj) //constructor
{
this->value= &obj;
jars++;
jarlist.push_back(this);
}
void destroy() //destroys a jar
{
{
typename deque<jar*>::iterator iter;
for (iter=jarlist.begin();iter!=jarlist.end();iter++)
{
if(*iter==this)
{
delete (*iter);
jarlist.erase(iter);
}
}
jars--;
}
}
};
template<typename T> int jar<T>::jars=0;
template<typename T> deque<jar*> jar<T>::jarlist; // <---------------------PROBLEM HERE---------------
int main()
{
int integer=3;
jar A(integer);
cout<<*(jar::jarlist.front())->value);
return 0;
}
any help would be greatly appreciated
Edited by xinfinite33, 22 December 2012 - 06:21 AM.






