Are the classes transferred to the heirs of the operation overloaded in the base class?

  • operations are overloaded with type, i.e. No, not transmitted. - vasily-vm
  • and the entry using TOutputPin :: operator =; Where is TOutputPin base class? - Konstantin Fomin
  • Give an example code. - yrHeTaTeJlb
  • In a derived class, you must explicitly define your constructors, destructors, and overloaded assignment operators because they are not inherited from the base class. But they can be called explicitly when defining a constructor, destructor, or overloading an assignment operator of a derived class, for example in the following way (for a constructor): Конструктор_Производного_Класса (/*параметры*/) : Конструктор_Базового_Класса ( /*параметры*/) { } - Alex.B
  • @yrHeTaTeJlb Well, I found a similar stackoverflow.com/questions/3882186/… - Konstantin Fomin

2 answers 2

As I understood from the question and comments, you wondered whether operator=() from the base class would be available in the class of the heir. No, it will not be available. The reason is that the compiler implicitly creates a copy assignment operator that hides all inherited overloads operator=() . To solve this problem, you can use the using -om:

 struct A{ int i; void operator =(int value){ i = value; } }; struct B : A{ using A::operator =; }; 

There should be no problems with other operators.

  • those. writing so I, in the class of the heir, say to use the operators of the parent class? what I was looking for. - Konstantin Fomin

As far as I understand from the question, you are interested in whether overloaded functions (that is, having several signatures) are transferred to the heirs. They are passed if public inheritance is used (as are non-overloaded functions):

 struct Base { int foo(int a); int foo(double a); }; struct Derived : public Base { // Наследует int foo(int a); // Наследует int foo(double a); }; 

But this rule does not apply to constructors, destructors and assignment operators. They must be defined explicitly, or (starting with C ++ 11) explicitly inherited - otherwise the compiler will automatically generate them, overlapping the parent ones. Related to this question, which you gave the link in the comments.