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

/// The baseclass providing the method you want to call in derived classes.
class Base {
public:
	explicit Base(const string& name)
		: m_name(name)
	{
	}
	
private:
	void private_method(const string& msg) // <= This is the method you want to call
	{
		cout << "Private method of " << m_name 
			 << " called with message: " << msg << endl;
	}
protected:
	static void call_private_method(Base& base_obj, const string& msg)
	{
		base_obj.private_method(msg);
	}
	
private:
	const string m_name;
};

/// A subclass providing some name.
class Foo : public Base {
public:	
	explicit Foo()
		: Base("Foo")
	{
	}
};

/// Another subclass with another name.
class Bar : public Base {
public:	
	explicit Bar()
		: Base("Bar")
	{
	}
};

/// Subclass that needs to call `private_method' on other subclasses of `Base`
class Accessor : public Base {
public:	
	explicit Accessor()
		: Base("Accessor")
		, m_objs()
	{
		m_objs.emplace_back(make_unique<Foo>());
		m_objs.emplace_back(make_unique<Bar>());
	}

	void call_em_out()
	{
		for(const auto& it : m_objs){
			call_private_method(*it, "success!");
		}
	}

private:
	vector<unique_ptr<Base>> m_objs;
};

int main() {
	Accessor accessor;
	accessor.call_em_out();
	return 0;
}