Assume I have the following abstract class and use it as an "interface" in C++:
class IDemo
{
public:
virtual ~IDemo() {}
virtual void Start() = 0;
};
class MyDemo : IDemo
{
public:
virtual void start()
{
//do stuff
}
};
Then in the class that need to have a handle to the interface (concrete class through injection):
class Project
{
public:
Project(IDemo demo);
private:
IDemo *_demo;
};
My intention is to assign concrete Demo class through the constructor of Project. This code doesn't compile since IDemo can't be instantiated. Any suggestions? Thanks in advance.