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
Static Members Static Data Members Static Member Functions
Static Data Members Data member whose value is shared by all the objects of the class Static data is allocated memory only once when the class is loaded. Must be defined outside the class Also can be initialized during definition, if not initial value will be 0. .
Static Data Members (Example) #include <iostream> using namespace std; class Demo private: static int X; public: static void fun() cout <<"value of X: " << X << endl; J; //defining int Demo: X -10; int main() Demo X; x.fun (); return ;
Static Member Functions Provide a very generic functionality that doesn't require us to instantiate the class. can be invoked without any objects (i.e. using class name) can access only other static members (static functions or static variables).
Input/output Statements cin is used for accepting data from the user cout is used for displaying information on the monitor cin and cout are declared in the header file iostream,h It should be included using #include<iostream> .
Examples cout<< " Enter your name : "; cin >> acName; // reads a string cout<< " Enter your Emp_ID and Salary: "; cin iEmpID> fSalary; // reads an integer and // a floating point number
Co-founder of BSI Academy and running YouTube channel. 5 years of teaching experience. Qualified in UGC NET & CSIR in Computer Science as JR