CLASS METHOD IN C++

Maha

CLASS METHODS

         The class functions are called methods. There are two ways to define functions that belongs to a class: Inside class definition. Outside class definition.

         The user-defined functions known as class methods in C++ can be used within an instance of the class. a notation of dots. is used to distinguish method names from regular functions.

Types of class methods are:

              * Inside class definition 

              * Outside class definition 

1. Inside class definition: 

                The member function can be directly defined because it is defined within the class definition. The dot operator (.) can be used to access the public member functions through the class object, just like we can access a data member in the class.

2. Outside class definition:

                  The scope resolution operator can be used to define the member function, which is defined outside of the class definition. The dot operator (.) can be used to access the public member functions through the class object, just like we can access a data member in the class.

Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send