Pointer Array for Template Class Objects

Started by
1 comment, last by Antheus 16 years, 1 month ago
is there any possible way to store pointers of one template function (different template arguments) in a std::vecotr ?? To get clear

class PrtclMan
{
public:
	int  add(CParticle *prtcl); 
	bool remove(int nr);
	void render();
private:
	std::vector <*CParticle> prtcls;
};
//this is CParticle
//template< typename T> class CParticle

So is there a way to store different CParticle Classes in one vector ?? Like CParticle <int> or CParticle <float> EDIT:: I found that url to be very helpful. Template Pointer [Edited by - Ben091986 on March 22, 2008 7:44:35 PM]
Advertisement
No, there isn't. The best you can do is inherit from a common base class, and store pointers to the base class in the vector.
std::vector<boost::any> particles;

Although the overhead and memory impact of the above isn't worth it. Use inheritance.

This topic is closed to new replies.

Advertisement