Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which concept allows different functions with the same name in C++ ?

  • A.Encapsulation
  • B.Function Overloading
  • C.Inheritance
  • D.Data Hiding

Answer: B

The concept is function overloading.

Function overloading lets several functions share one name as long as their parameter lists differ in number or type, for example area(int) for a square and area(int, int) for a rectangle. The compiler picks the right one from the arguments at each call, which makes it a form of compile-time polymorphism.

Encapsulation bundles data with the functions that act on it. Inheritance lets a class derive members from another class. Data hiding restricts access to a class's internals with private and protected members. None of these allows two functions with the same name.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.