AbhishekSaini132328
66 views
7 slides
Jan 25, 2022
Slide 1 of 7
1
2
3
4
5
6
7
About This Presentation
You can present your presentation on the topic of member function in c++ with very easy examples.
Size: 214.46 KB
Language: en
Added: Jan 25, 2022
Slides: 7 pages
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…