I have a class Test which implements to different interface Interface1 and Interface2. There is a FactoryClass that creates an object of this class Test.
class Interface1{
virtual void function1() = 0;
};
class Interface2{
virtual void function2() = 0;
};
class Test(): public Interface1, public Interface2{
void function1()
{
}
void function2()
{
}
};
class FactoryClass
{
Interface1* createInstance() {
Interface1* interface1 = new Test();
return interface1;
}
};
void main()
{
Interface1* int1 = FactoryClass::createInstance();
int1->function1();
}
I need a solution to access function2 via interface2 wihtout doing new again?