Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Base {
- public:
- virtual void doSomething() {
- cout << "Base::doSomething()" << endl;
- }
- };
- class Derived : public Base {
- private:
- void doSomething() override {
- cout << "Derived::doSomething()" << endl;
- }
- };
- int main(int argc, char* argv[])
- {
- auto b = unique_ptr<Base>(new Base);
- b->doSomething();
- auto b2 = unique_ptr<Base>(new Derived);
- b2->doSomething();
- auto d = unique_ptr<Derived>(new Derived);
- d->doSomething();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement