I am trying to use a function from base class to child class but couldn't figure out how to do this.
This is my simplified program :
class CPerson
{
public:
CPerson() = default;
void print() {std::cout <<"test"<<std::endl;}
};
class CStudent : private CPerson
{
public:
CStudent() = default;
};
class CTeacher : private CPerson
{
public:
CTeacher() = default;
};
class CTutor : public CTeacher , public CStudent
{
public:
CTutor() = default;
void test()
{
CPerson::print(); //Error is here
}
};
So the error that I had first was
base class "CPerson" is ambiguous
To fix this issue I had to change class CStudent : public CPerson
to
class CStudent : private CPerson
and class CTeacher : public CPerson
to class CTeacher : private CPerson
.
But in this case I will get another error ,
`type "CPerson::CPerson" is inaccessible`
and to fix this I have to change the classes again to public instead of private . But I will end again with the first error . So I'm kinda stuck here