这是场景:
class Base {
public:
typedef Base type;
};
class Derived: public Base {
public:
typedef Derived type;
};
我想要类似的东西:
int main() {
Base * bs = new Derived();
decltype(*bs)::type newvar;
}
如何在不使用静态/动态转换的情况下执行上述操作来获取 Derived 类的类型?