D
Dilip
Hi
This is more of a "is-this-really-the-right-way-to-do-this" style of
question.
I have a class hierarchy resembling:
class base
{
};
template<typename T>
class derv : public base
{
};
// elsewhere...
std::vector<base*> baseptrs;
baseptrs.push_back(new derv<int>());
Now if I want to downcast from base to derv -- is the syntax for that:
derv<int>* pObj = dynamic_cast<derv<int>* >(baseptrs.at(0));
I am a little unsure. if I end up having more than 2 template
parameters in a class, doesn't this kind of syntax quickly get hairy
(ignoring the fact that I may have to rethink the use of dynamic_cast
anyway)
This is more of a "is-this-really-the-right-way-to-do-this" style of
question.
I have a class hierarchy resembling:
class base
{
};
template<typename T>
class derv : public base
{
};
// elsewhere...
std::vector<base*> baseptrs;
baseptrs.push_back(new derv<int>());
Now if I want to downcast from base to derv -- is the syntax for that:
derv<int>* pObj = dynamic_cast<derv<int>* >(baseptrs.at(0));
I am a little unsure. if I end up having more than 2 template
parameters in a class, doesn't this kind of syntax quickly get hairy
(ignoring the fact that I may have to rethink the use of dynamic_cast
anyway)