Quick question:
Would this be an 'acceptable' template usage? I'm thinking it would be convenient in that it eliminates the need for typecasting everything to void*, but it might also gets rid of typesafety in some way (though I'm not sure exactly what). Also, I'm concerned that it may generate additional code, bloating the executable slightly (relative to a manual typecast by the user), with no speed benefit at all.Code:class A
{
public:
//Some other stuff
template <typename T>
void setData(T* data) {userData = (void*)data;}
template <typename T>
T* getData() {return (T*)userData;}
protected:
void* userData;
};
Comments anyone?
[unrelated edit]Also, if you don't write any constructors for a derived class, will the corresponding constructors of the base class be called by default? [/unrelated edit]
[Edit 2]And, I'm having problems finding anything useful on Google - but is it safe to delete a pointer to void (delete, not delete[])? [/Edit2]