Most of people thing that opp is a language. Most of people thing C++ is oop. But it is not true – opp is a concept which is followed by several languages like. C++, c#, java, j# etc. Simula is the first language which follow the opp`s concept in 1960. In opp, every thing is in form of class and object. Opp is like religion and language are like people who follow the religion.
Class – Class is a keyword which is use to create a user define data type. Through which we can access different-2 fundamental data type, which are declare inside the class. Class allocate memory in form of stack, at compilation time. It’s mean is it, that the memory of class is always fixed. ( at compilation time ).
Object – Object is an instance of a class. Object always created at run time. Object is a collection of variables which are inside the class. Type of object – There are mainly two type of object – 1. Qualified object 2. reference object Virtual object Qualified object – Actually when we talking about the qualified object, it’s mean is it we are talking about the object. Qualified object allocate memory in heap portion of ram
Reference object – A such type of object, which does not allocate any separate memory. It take space in the stack of the class. Function- 1. function is an entity which perform some specific task. 2. function always return a value. 3. every program has at least one function, if only one function then that is main ( );
Type of function – 1. member function. 2. parameterized function. 3. static function. 4. friend function. 5. virtual function. 6. pure virtual function. Member function – 1. a function which is define inside the class and call by it’s object is known as member function. Parameterized function – A member function which take parameters as argument is known as parameterized function.
Static function – A function which is not call by object but call by the class name. We can also say’s that a static function follow the principle of class but dont follow the principle of object. Friend function – A function which does not follow the principle of class and object means. It is directly call by it’s name, is known as friend function.
Constructor – Constructor is a special type function. Which name is same to class name. Constructor never return a value. Constructor never inherited. Constructor is use to initialized the qualified object, we can also says that it allocate memory for qualified object. Type of constructor – 1. default function. 2. parameterized function. 3. copy constructor.
Default constructor – A constructor which does not take any parameter and initialized the qualified object, is known as default constructor. Parameterized constructor – A such type of constructor which takes argument in form of parameter is known as parameterized constructor. Copy constructor – A parameterized constructor which take parameter as the copy of on object is known as copy constructor.
Destructor – Destructor is similar to constructor, it’s name is also same to class name & it also never return any value and never inherited. It is use to deallocate the memory location of qualified object. We can also says that it deallocate the heap. Polymorphism – Polymorphism is a concept, same name function their working is different and call by a single object is known as polymorphism. Type of polymorphism – 1. static polymorphism. 2. dynamic polymorphism.
Static polymorphism – We use function overloading, to achieve static polymorphism. Same name function, their return type may be same and they are define in a same class only one difference they take different parameter. When a single object call these functions, it is known as function overloading and this implementation call static polymorphism. Dynamic polymorphism – Dynamic polymorphism is also known as runtime polymorphism achieve dynamic polymorphism, we required – 1. Inheritance. 2. function overriding.
Inheritance – It is a concept of oop, through which we can access the property of one class from another class. Inheritance always perform between two objects. A class which access the property is known derived class and a class whose property is access is known bass class. Type of inheritance – 1. Single level inheritance. 2. Multi level inheritance. 3. Multiple inheritance. 4. Hierarchical. 5. Hybrid.
Virtual function – We know that we can not acass the derive class function from base class object. So we use the concept of virtual function if we declare a function as virtual then it can be call by base class object. Virtual object – We know that inheritance always perform between two objects. We are able to see the object of derive class but we can not see the object of base class. For inheritance object must be created so we represent base class object as virtual object. It has no memory but all the variables and function of that object take space in virtual table.
Pure virtual function – A such type of function which use the keyword virtual and initialized by o (zero) is known as pure virtual function. If any class contain a pure virtual function then no object of that class created. “ The body of pure virtual function is not with it ”. If any class inherited the class which have pure virtual function, then derive class also become obstruct till it does not define pure virtual function. abstract class – A class which contain a pure virtual function is known as abstract class. The object of this class never created. Interface – A such type class which all functions are pure virtual function is known as interface.