I have a number of classes forming a class hierarchy with base classes and their inheritances. Each class is quite large by taking several responsibilities, although those responsibilities are not coupled. I put the different responsibilities together in a class because I can easily use them consistently(I cannot express it very clearly, please see the illustrating code). But this seems not a good design. How can I split the large class while keeping it easy to use? Thanks for your suggestion and comments! The below please find the illustrating code.
// Base class.
class Base
{
public:
// For responsibility A
virtual void A1();
virtual void A2();
...
// For responsibility B
virtual void B1();
virtual void B2();
...
// More responsibilites.
...
};
// Derived class 1.
class Derived_1 : public Base
{...};
// More derived classes.
...
// A function use it.
void Fun()
{
Base* p = new Derived_1;
p->A1(); // Here A1 and B1 are binded in the class Base, thus it make sure
p->B1(); // their uses are consistent. If they are separated, how to ensure it?
}