#include <iostream>
#include <vector>
using namespace std;

    class A
    {
    public:
      virtual void call_bar() = 0;
      virtual ~A() {}
    };

    template <typename T>
    class B : public A
    {
    public:
      virtual void call_bar() override
      {
        bar(static_cast<T*>(this));
      }
    };
    
    class C: public B<C>
    {
    };
    
    void bar(C* c)
    {
    	cout << "C" << endl;
    }
    
    typedef std::vector<A*> a_list;

int main() {
	C c;
	A* a = &c;
	a->call_bar();
	
	a_list b;
	b.push_back(a);
	for(auto& ref : b)
		ref->call_bar();
	// your code goes here
	return 0;
}