static & template

G

Guest

I think, a class template with a static vector member:
----------------------------
template <class C>
struct Shared
{
unsigned int count;
C data;
};

template <class C>
class SharedObject
{
public:
............

protected:
Shared<C> *pointer;
static vector <Shared<C>*> pointers;
};
----------------------------
Is it valid in C++?

Ofcourse, if C is class Texture2D or C is class Model3D I want 2 different static vectors:
All SharedObject<Texture2D> must have the same static vector<Texture2D>
and
All SharedObject<Model3D> must have the same static vector<Model3D>

Is this possible?

thanks
 
R

Rob Williscroft

I think, a class template with a static vector member:
----------------------------
template <class C>
struct Shared
{
unsigned int count;
C data;
};

template <class C>
class SharedObject
{
public:
............

protected:
Shared<C> *pointer;
static vector <Shared<C>*> pointers;
};
----------------------------
Is it valid in C++?

Ofcourse, if C is class Texture2D or C is class Model3D I want 2
different static vectors: All SharedObject<Texture2D> must have the
same static vector<Texture2D> and

static vector said:
All SharedObject<Model3D> must have the same static vector<Model3D>

Is this possible?

Typo's aside, Yes, that's how static members work.

Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,918
Members
47,458
Latest member
Chris#

Latest Threads

Top