I am writing an application in c++.
I have an interface defined with various functions:
class ITest
{
public:
virtual void x()=0;
virtual void y()=0;
}
I then have a class that implements this interface, along with additional functions:
class NewClass: public ITest
{
public:
virtual void x();
virtual void y();
// new function not defined in interface
virtual void z();
}
I now want to access all of these 3 functions from my unit tests.
Currently I am using:
ITest* pTest;
which will only give me access to the 2 functions defined in the interface.
How can I also gain access to function z() without defining it in the interface?
Instead of
dynamic_cast, you can usestatic_cast. But ifpTest‘s dynamic type is not actuallyNewClass*you’ll get undefined behavior.