Here is my code -
#include
using namespace std;
class base
{
public:
void sid()
{
}
};
class derived : private base
{
public:
You know that class derived
inherits from class base
, but the main()
function doesn't know it. The reason the main()
function doesn't know it is that you made class derived
inherit PRIVATELY from class base
.
Therefore when you try to assign new derived
to ptr
, the pointer types are not compatible.