2021年2月10日星期三

Type casting objects without pointers

I'd like to type cast from a base class to a derived class. For example:

class A {};  class B : public A {}  A a;  // do stuff with a  B b = (B)a;  

This works fine with B* b = (B*)&a; but I'm trying to avoid that. Is this possible?

https://stackoverflow.com/questions/66147712/type-casting-objects-without-pointers February 11, 2021 at 09:53AM

没有评论:

发表评论