Defining Member Functions in C++ || Inside the Class || Outside the Class || C++ Programming

preview_player
Показать описание
#cpluspluslectures #DefiningMemberFunctionsinCplusplus #cplusplusplaylist

Member functions of a class can be defined either outside the class definition or inside the class definition. In both the cases, the function body remains the same, however, the function header is different.
Outside the Class: Defining a member function outside a class requires the function declaration (function prototype) to be provided inside the class definition. The member function is declared inside the class like a normal function. This declaration informs the compiler that the function is a member of the class and that it has been defined outside the class. After a member function is declared inside the class, it must be defined (outside the class) in the program.

The definition of member function outside the class differs from normal function definition, as the function name in the function header is preceded by the class name and the scope resolution operator (: :). The scope resolution operator informs the compiler what class the member belongs to. The syntax for defining a member function outside the class is
nside the Class: A member function of a class can also be defined inside the class. However, when a member function is defined inside the class, the class name and the scope resolution operator are not specified in the function header. Moreover, the member functions defined inside a class definition are by default inline functions.

To understand the concept of defining a member function inside a class, consider this example.
Рекомендации по теме
Комментарии
Автор

Tq so much sir😇😇😇😇😇😇
. Feeling happy on seeing ur teaching U teach very clearly... Crystal clear explanation 👌

thrisha
Автор

It's really very helpful sir.. Tnx a lot

vennilab
Автор

cout<<"Thank you so much sir”;

prasadsapkal
Автор

Why we are using string in inside the class program instead of s2.get_data()?

belistamercy
Автор

Sir how we can identify char name[20] come under public

shivaleelatirumalesh