Member Function in C++

AbhishekSaini132328 66 views 7 slides Jan 25, 2022
Slide 1
Slide 1 of 7
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7

About This Presentation

You can present your presentation on the topic of member function in c++ with very easy examples.


Slide Content

Presented By – ABHISHEK SAINI Member Function in C++

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. Example :- class student{ public: void myStudent () { ……………… statements ………………. } }; What’s a Member Function ? 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. Example – class student { public: void myStudent (); }; void student :: myStudent () { ………………. statements ……………….. } Scope Resolution Operator Member function prototype declaration

Calling a Member Function 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 (.). Example - int main() { class_name obj_name ; obj_name.member_function_name ; } Dot Operator

Data Member and Function Data Member and Function Private Public Not accessible from outside the class Accessible from outside the class Class

Lets’s do some Practical…. Some basic of member function… lets code…

Thank YOU :) 