#include <iostream>
#include <conio>

class ObjFuncVirtual
{
	public :
		virtual void operator ()(void) const {cout << "Base" << endl;}
};

class ObjFuncDerived1 : public ObjFuncVirtual
{
	public:
		virtual void operator ()(void) const {cout << "Func1" << endl;}
};

class ObjFuncDerived2 : public ObjFuncVirtual
{
	public:
		virtual void operator ()(void) const {cout << "Func2" << endl;}
};

class ObjFuncDerived3 : public ObjFuncVirtual
{
	public:
		virtual void operator ()(void) const {cout << "Func3" << endl;}
};

void FFunc1(ObjFuncVirtual F)
{
	F();
}

void FFunc2(const ObjFuncVirtual &F)
{
	F();
}

void FFunc3(ObjFuncVirtual *PF)
{
	(*PF)();
}


int main(void)
{
	ObjFuncDerived1 O1;
	ObjFuncDerived2 O2;
	ObjFuncDerived3 O3;

	FFunc1(O1);
	FFunc1(O2);
	FFunc1(O3);
	cout << endl << endl;

	FFunc2(O1);
	FFunc2(O2);
	FFunc2(O3);
	cout << endl << endl;

	FFunc2(ObjFuncDerived1());
	FFunc2(ObjFuncDerived2());
	FFunc2(ObjFuncDerived3());
	cout << endl << endl;
	
	FFunc3(&O1);
	FFunc3(&O2);
	FFunc3(&O3);

	getch();
	return 0;
}
