By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,614 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

static & template

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
<- Chameleon -> wrote in news:c7*********@nic.grnet.gr in comp.lang.c++:
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< Shared< Texture2D > * >
All SharedObject<Model3D> must have the same static vector<Model3D>

Is this possible?


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

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.