difference between function hiding and overloading

  • A+

I can't find any difference between function hiding and overloading. As the function hiding is the function that is present in derived class and hides the function of a base class. Having same name of the function in both of them. Overloading: having same name but different signature in both derived and base class.

class A {     void print(int); }; class B: public A {     void print(float); }; 

does it hide function or overload ?


The function B::print hides the parent function A::print.

If you want to overload you need to pull in the A::print function into the scope of B:

class B : public A { public:     using A::print;  // Pull in (all) A::print symbols into the scope of B      void print(float);  // Now overloads A::print }; 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: