In languages like C++, we can inheritance in two ways.
#include <iostream>
class Base {
public:
void base_function() {
std::cout << ("Base-Class function\n");
}
};
class Derived1: public Base {
// we can call base_function on object of class Derived1
};
class Derived2 : private Base {
public:
void derive_function() {
std::cout << "We can call base_function only inside methods\n";
base_function();
}
};
Private inheritance - It means that we inherit the implementation, but we are not a type of BaseClass.
Public inheritance - It means that we inherit the interface, so we are a type of BaseClass.
Is there a way in python to actually create something that will act as a private inheritance? Are there any python tricks? Or we must base a solution on Association/Aggregation/Composition?