Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Foo {
- private:
- int a = 0;
- public:
- void doA() {
- a += 1;
- cout << "a=" << a << endl;
- }
- virtual void doB() = 0;
- };
- class Bar: private Foo {
- public:
- static Foo *createFoo() {
- return new Bar();
- }
- void doB() {
- doA();
- }
- };
- int main()
- {
- Foo *f = Bar::createFoo();
- f->doA();
- f->doB();
- delete f;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement