#include <iostream>
class c1{
};
class c2{
};
int main(){
c1 a;
c2 b;
//b = static_cast<c2>(a); <-- will not compile
b = *reinterpret_cast<c2*>(&a);
return 0;
}
b = static_cast<c2>(a);
will not compile with this error:
no matching conversion for static_cast from 'c1' to 'c2'
Is using reinterpret_cast
and doing a bit cast
the only way of accomplishing this?