NTA UGC NET Paper -2
Computer Science & Application
About Me Sandeep M.Tech (IT) from IIIT CSIR (Engineering Science) as JRF UGC NET (JRF) - Computer Science & Applications Worked as Software Engineer & Research Scientist
Object - Oriented Programming
unacademy Follow me on the Unacademy Learning App 127.1k Sandeep Singh Educator since May 201 Co-founder of BSI Academy. 5 years of teaching Qualified in UGC NET in Computer Science and its Get updates about new courses Watch all my lessons Application as JRF& lecturer 14.7k 0 34 Follow . Download slides and watch offline All courses Q Sandeep Singh HINDI Programming in C&C (Hindi) Concepts of Objects Oriented Programming: CBSE UGC NET 0(6 ratings Sandeep Singh
Friend Function Friend Function that is a "friend" of a given class is allowed access to private and protected data in that class.
Friend Function The declaration of friend function should be made inside the body of class (can be anywhere inside clas either in private or public section starting with keyword friend.
Syntax class class name friend returntype function_name(arguments);
Friend Class Friend function a class can be made a friend of another class using keyword friend.
Example Friend function #include<iostream.h> #include<conio.h> class employee private: friend void sal); 3; void sal() int salary-4000; cout<<"Salary: "<<salary; void main(C) employee e; e.sal() getch);
Example class Employee //Overloaded constructor with int parameter Employee(int id)( this->idid; int id string name; public: //Overloaded constructor with a int parameter and a string nstructo Employee(int id, string name)\ Employee() this->id-id; this->namename this->id0; this->name- "default " ; void display()f cout << "Employee Info: "<<" " << id << " " << name.c_str)<<"\n";
Co-founder of BSI Academy and running YouTube channel. 5 years of teaching experience. Qualified in UGC NET & CSIR in Computer Science as JR