In C++, what is the term for a function that is defined inside a class definition? Choose the standard name used in OOP and C++.

Difficulty: Easy

Correct Answer: Member function

Explanation:


Introduction:
C++ classes bundle state and behavior. The behavior is implemented through functions associated with the class. This question asks for the conventional term for those functions.


Given Data / Assumptions:

  • A function appears in the class body.
  • It may be declared and defined inside the class, or declared inside and defined outside with ClassName:: scope.
  • We use standard OOP terminology.


Concept / Approach:
Functions that belong to a class are called member functions (a.k.a. methods). They operate on class instances, may access this, and may be const/non-const, static or virtual, etc. “Member variable” refers to data, not behavior; “class function” is informal and ambiguous; “classic function” is unrelated.


Step-by-Step Solution:
1) Identify that the function is part of a class.2) Recognize the established term: member function.3) Note that placement of the definition (inside vs outside) does not change the term.4) Conclude the correct choice is “Member function”.


Verification / Alternative check:
Any C++ text or reference uses “member function” and “data member” consistently to distinguish behavior from state.


Why Other Options Are Wrong:
Member Variable: that is state (data), not behavior.Class function: non-standard term; may confuse with static functions.Classic function: unrelated phrase.


Common Pitfalls:
Assuming static member functions are not “member functions”—they are still members, but lack a this pointer.


Final Answer:
Member function

More Questions from OOPS Concepts

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion