Is it possible to define a certain method in the parent class so that different descendants have a different number of input parameters for it? Let it be considered, for example, that these parameters can only be 3, 4 or 5, they have a type known in advance (in my case it is one int (the number of subsequent parameters, I want to get rid of it) and 2-4 parameters of the type Particle I created) ; the return value is of type float. That is, I would like, for example, to do this:
class PotentialAbstract { public: virtual float E(int particlesNumberInFormula, ...) = 0; }; // потомок, метод которого зависит от трёх параметров class PotentialForBond : public PotentialAbstract { public: float E(int particlesNumberInFormula, Particle p1, Particle p2); } // потомок, метод которого зависит от четырёх параметров class PotentialForAngle : public PotentialAbstract { public: float E(int particlesNumberInFormula, Particle p1, Particle p2, Particle p3); } // и так далее The particle particlesNumberInFormula, however, I, in fact, do not need, because every potential knows without it what number of particles it depends on. Simply, as I understand it, to parse the parameters in the called method, you need to get the address of the first one, only therefore I pass such a variable to the method. Next, you have to work with raw pointers; when using shared_ptr, how to act is unclear to me. Ideally, I would like the idea of a fast-working method. For example, it seems to me that using std :: vector as an input parameter will be slow (or am I wrong?). Well, just out of curiosity: is it possible to make descendants with different numbers of input parameters in the same method being redefined? Thanks in advance for your reply.