Aug
15
comment C++ base class reference initialize with different derived class object
And using ternary operator with unique_ptr::reset() is neat!
Aug
15
comment C++ base class reference initialize with different derived class object
This is actually a working solution, but with redundant object. I'll accept billz's answer as correct one.
Aug
15
awarded Supporter
Aug
15
awarded Scholar
Aug
15
comment C++ base class reference initialize with different derived class object
Although this uses pointer, still the best answer for my need.
Aug
15
accepted C++ base class reference initialize with different derived class object
Aug
15
comment C++ base class reference initialize with different derived class object
Using pointer means I have to use obj->operator(), and lose the natural syntax of operator overloading.
Aug
15
awarded Student
Aug
15
asked C++ base class reference initialize with different derived class object
Apr
17
awarded Enthusiast