I came across this in one of the posts on SO. I find it hard to understand the following code.
class A { public: virtual void foo() = 0; private: virtual void bar() = 0; }; class B : public A { private: virtual void foo() { std::cout << "B in Foo \n"; } public: virtual void bar() { std::cout << "bar in Foo \n"; } }; void f(A& a, B& b) { a.foo();
Now I wanted to know how line A is possible? classA will usually be an interface and you cannot create one. You could only implement its implementation. I would appreciate it if someone could explain to me what is going on here.
Update:
can be considered a in LineA as an implementation of b?
source share