Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <memory>
- #include <iostream>
- class Mesh {
- public:
- static const int a = 1;
- };
- class Light {
- public:
- static const int a = 2;
- };
- class Object : public Mesh, public Light {
- };
- template <typename T>
- std::shared_ptr<Object> createObject() {
- return std::static_pointer_cast<Object>(std::make_shared<T>());
- }
- int main() {
- auto ptr = createObject<Mesh>();
- std::cout << ptr->Mesh::a;
- auto btr = createObject<Light>();
- std::cout << btr->Light::a;
- }
Advertisement
Add Comment
Please, Sign In to add comment