3
3nc0d3d
I have needed to cast a pointer with different types for get a value.
I have try to use generic, but there are cast exception.
For example the following method:
generic<typename T> void XClass::GetValue(T gValue)
{
int iValue=34234234;
void *vValue=&iValue;
gValue=(T)*vValue;
}
can't be used for compile error (a illegal indirection method)
modifying the method in this way:
generic<typename T> void XClass::GetValue(T gValue)
{
int iValue=34234234;
void *vValue=&iValue;
unsigned long ulValue;
ulValue=*((unsigned long*)vValue);
gValue=(T)ulValue;
}
there's a runtime error (Specified cast is not valid)
How can I to use generic for this goal?
Thanks for reply
EncOdEd
I have try to use generic, but there are cast exception.
For example the following method:
generic<typename T> void XClass::GetValue(T gValue)
{
int iValue=34234234;
void *vValue=&iValue;
gValue=(T)*vValue;
}
can't be used for compile error (a illegal indirection method)
modifying the method in this way:
generic<typename T> void XClass::GetValue(T gValue)
{
int iValue=34234234;
void *vValue=&iValue;
unsigned long ulValue;
ulValue=*((unsigned long*)vValue);
gValue=(T)ulValue;
}
there's a runtime error (Specified cast is not valid)
How can I to use generic for this goal?
Thanks for reply
EncOdEd