I get the following error with VS2008: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
When casting a down casting a ClassA to ClassA_1 and ClassA_1 is a templated class that received an enum for parameter such as:
THIS IS AN EDIT OF MY QUESTION WHICH RE-USE AN ANSWER BELOW BUT MODIFED TO CAUSE THE PROBLEM I AM HAVING, here we go:
Ok i have been able to reproduce my error with this code:
class ClassA
{
public:
virtual ~ClassA(){}
};
template <class Param1 = void*> class ClassB : public ClassA {
public:
//constructor
ClassB(Param1 p1 = NULL)
{
_p1 = p1;
}
//ClassB(const ClassB<Param1>& ref);
Param1 _p1;
~ClassB(){}
};
enum lolcakes {
cakeisalie,
};
ClassA* ptr = new ClassB<lolcakes>(lolcakes::cakeisalie);
ClassB<lolcakes>* a1 = (ClassB<lolcakes>*)ptr;