I have two classes A and B, B is inherited from A:
now I’m having a function take a parameter of TSubclassOf<class A>
//declare of function
foo( TSubclassOf<class A> varClass )
However, I want to pass the parameter as TSubclassOf<class B>
//declare of varClass
TSubclassOf<class B> varClass
//try to call foo by this variable
foo( varClass )
the compiler will send err:
error C2440: ‘initializing’ : cannot convert from ‘B*’ to ‘A*’
How should I avoid this? Since I found it really convenient of declaring varClass as TSubclassOf<> instead of UClass*.
I will prefer using TSubclassOf<> if I can solve this question.