I would like to know if in c ++ you can increment an existing class by inserting new methods, without directly manipulating the source code of the class.
For example, if the class below is part of an external library that should not be changed, it contains 2 methods:
class original
{
public:
void metodo1() {
std::cout << "método 1" << endl;
}
void metodo2() {
std::cout << "método 2" << endl;
}
};
Then inside my code, I would like to increment this class by inserting a third method:
void metodo3() {
std::cout << "método 3" << endl;
}
How would that be possible?