[ create a new paste ] login | about

Link: http://codepad.org/cGsBF3Ba    [ raw code | output | fork ]

C++, pasted on Feb 16:
#include <iostream>
#include "AbstractFactoryClass.h"
#include "TypesCollection.h"

class Base1
{
public:
	virtual ~Base1() {}
	virtual void print_name()
	{
		std::cout << "Base1" << std::endl;
	}
};

class Base2
{
public:
	virtual ~Base2() {}
	virtual void print_name()
	{
		std::cout << "Base2" << std::endl;
	}
};

class Derived1 : public Base1
{
public:
	void print_name()
	{
		std::cout << "Derived1" << std::endl;
	}
};

class Derived2 : public Base2
{
public:
	void print_name()
	{
		std::cout << "Derived2" << std::endl;
	}
};

int main() 
{
        typedef AbstractFactory<TYPECOLLECTION_2(Base1, Base2)> AbstractBaseFactory;
	typedef AbstractFactoryImpl<AbstractBaseFactory, ProductCreatorUsingNew, TYPECOLLECTION_2(Derived1, Derived2)> DerivedFactory1;

	DerivedFactory1 factory;
	Base1* ptr1 = factory.Create<Derived1>();
	Base2* ptr2 = factory.Create<Derived2>();
	ptr1->print_name();
	ptr2->print_name();
}


Output:
1
2
3
4
5
Line 33: error: AbstractFactoryClass.h: No such file or directory
Line 28: error: TypesCollection.h: No such file or directory
In function 'int main()':
Line 45: error: expected initializer before '<' token
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: