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

  Рет қаралды 10,301

Sudhakar Atchala

Sudhakar Atchala

Күн бұрын

#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.

Пікірлер: 17
@3thrisha869
@3thrisha869 2 жыл бұрын
Tq so much sir😇😇😇😇😇😇 . Feeling happy on seeing ur teaching sir..... U teach very clearly... Crystal clear explanation 👌
@SudhakarAtchala
@SudhakarAtchala 2 жыл бұрын
Welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.
@3thrisha869
@3thrisha869 2 жыл бұрын
@@SudhakarAtchala sure sir
@kidsgametube
@kidsgametube 4 жыл бұрын
Excellent.
@hunter-ajithkumar8104
@hunter-ajithkumar8104 2 жыл бұрын
Thank you for your teaching
@SudhakarAtchala
@SudhakarAtchala 2 жыл бұрын
Welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.
@vennilab9657
@vennilab9657 3 жыл бұрын
It's really very helpful sir.. Tnx a lot
@SudhakarAtchala
@SudhakarAtchala 3 жыл бұрын
So nice of you Balaguru. Plz subscribe to the channel and if possible share with your friends. Thanks
@prasadsapkal9529
@prasadsapkal9529 2 жыл бұрын
cout
@SudhakarAtchala
@SudhakarAtchala 2 жыл бұрын
Welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.
@akshay3849
@akshay3849 2 жыл бұрын
Thanks
@SudhakarAtchala
@SudhakarAtchala 2 жыл бұрын
Welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.
@belistamercy4706
@belistamercy4706 2 жыл бұрын
Why we are using string in inside the class program instead of s2.get_data()?
@SudhakarAtchala
@SudhakarAtchala 2 жыл бұрын
It's ur choice. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.
@shivaleelatirumalesh1135
@shivaleelatirumalesh1135 3 жыл бұрын
Sir how we can identify char name[20] come under public
@SudhakarAtchala
@SudhakarAtchala 3 жыл бұрын
It is private member variable only but by using public member function of the class we can access that private member variable. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.
Friend Function In C++ Programming
14:38
Sudhakar Atchala
Рет қаралды 12 М.
这到底是怎么做到的 #路飞#海贼王
00:10
路飞与唐舞桐
Рет қаралды 4 МЛН
Inline Functions in C++ || C++ Programming
10:27
Sudhakar Atchala
Рет қаралды 12 М.
Constructor in C++ | Types | OOPs in C++ | Lec-17 | Bhanu Priya
18:24
Class Member Function Definition | C ++ Tutorial | Mr. Kishore
18:52
Naresh i Technologies
Рет қаралды 85 М.
Class Member Functions (aka Methods) | C++ Tutorial
7:18
Portfolio Courses
Рет қаралды 29 М.
Pure Virtual Functions In C++ ||  Abstract Class In C++
7:11
Sudhakar Atchala
Рет қаралды 11 М.
ACCESS SPECIFIERS (PUBLIC, PRIVATE, PROTECTED) - C++ PROGRAMMING
17:46
Sundeep Saradhi Kanthety
Рет қаралды 56 М.