The functions declared inside the class are knows as
Member Function and works on the data members of the
class. The definition of member functions can be inside or
outside the class.
class student{
public:
void myStudent()
{
………………
statements
……………….
}
};
Class keyword
Member function
Class name
If the member function is defined inside the
class definition it can be defined directly, but if
its defined outside the class, then we have to
use the scope resolution :: operator along with
class name along with function name.
Member function
prototype declaration
Similar to accessing a data member in the
class, we can also access the public
member functions through the class object
using the dot operator (.).
-
Dot Operator
Not accessible from outside
the class
Accessible from outside the
class
lets code…
Member Function in C++

Member Function in C++

  • 2.
    The functions declaredinside the class are knows as Member Function and works on the data members of the class. The definition of member functions can be inside or outside the class. class student{ public: void myStudent() { ……………… statements ………………. } }; Class keyword Member function Class name
  • 3.
    If the memberfunction is defined inside the class definition it can be defined directly, but if its defined outside the class, then we have to use the scope resolution :: operator along with class name along with function name. Member function prototype declaration
  • 4.
    Similar to accessinga data member in the class, we can also access the public member functions through the class object using the dot operator (.). - Dot Operator
  • 5.
    Not accessible fromoutside the class Accessible from outside the class
  • 6.