How to competently implement a class type constructor:

class NewClass { public: NewClass(Class1 &Name1, Class2 &Name2 ) ... }; 

if the number of different classes Class1 and Class2 significant?

For a small number of classes (Class1 and Class2), you can manually sort through all possible constructor overloads, and what if there are many such classes or an arbitrary number?

  • one
    Maybe just put these classes in an array (or vector) and pass to the constructor? - user263096 pm
  • I am not sure that I understood the essence))) I will try to concretize the question. This code is used to implement the hydraulic network calculation. And it will output as follows (for example): class Pipe {public: Pipe (Tank & pipeEnd1, Node & pipeEnd2) ...}; those. class tube and two objects at its ends of the class tank and class connection. But there are many possible variations, at least 5-6 different classes. - DmitriyS

0