说我有
class A { }; class B { }; using AOrB = boost::variant <A,B>; A* ptr2a = .... AOrB* another_ptr2a = a;//this doesn't compile for me, what is the correct way to do it?
使用boost :: variant *是不好的做法吗?
说我有A类{}; B类{};使用AOrB = boost :: variant ; A* ptr2a = .... AOrB* another_ptr2a = a;//this doesn't compile for me, what is the correct way to do it? is using ...
你不能。 AOrB
由A
子对象或B
子对象组成,这些对象都不能指向现有的A
。
您可以将A
复制到AOrB