Knowledge in OBJECT ORIENTED PROGRAMMING USING C++

OBJECT ORIENTED PROGRAMMING USING C++

It contains notes for Engineering OBJECT ORIENTED PROGRAMMING USING C++ subject

Object Oriented Programming through C++

C++ OOPs Concepts. The major purpose of C++ programming is to introduce the concept of object orientation to the C programming language. Object Oriented Programming is a paradigm that provides many concepts such as inheritance, data binding, polymorphism etc.

Program to implement static data members

Here static variable is introduced . Syntax of implementing static variable is : static data type variable name; Ex: static int a Here using class ,objects are created. Ex: class test put data() ,get data() are used to print and scan the inputs and outputs...same as printed and scanf .

Program to implement friend function

Friend function is used to access the private data members of a class. The syntax of implementing friend function is : Friend data type show (class name); Ex: friend void show(sample); The above mentioned program explains just to assign the values to the variables and how can a friend function access those data members.

Virtual base class

Virtual base classes are used in virtual inheritances. Using the word virtual before class represents that to avoid the multiple instances of a virtual inheritance. It means that we want that to be a single time. Virtual base class is analogous to virtual inheritance. It is used in 'Run time polymorphism' . Let us consider an example of w,x,y,z . W is derived from class x and y. here x and y are previously derived from z. It means multiple instances of inheritance.

Program to explain how the constructor & destructor are invoked in inheritance.

Firstly inheritance means to aquire the properties of previously existing classes. Here constructors initialize the member variable where as destructor destroys the data object. Using these two terms we invoke inheritance. It means to exhibit the properties of the existing class or object.

Program to explain pointer variable 'this'.

The 'This' pointer variable is used to point the current object of a class in simple words. The this pointer variable is also used to return the reference of the current object of a class so that we can chain the function calls. This results in the chaining of a function calls at one go. There are many advantages of this pointer variable.

Program to explain 1-D array using pointers.

Let us first know what is pointer? A pointer *ptr is a variable which stores the address of another variable. Here 1-Dimensional arrays use simole array concept. In this program the elements of array are initialized first and then introducing pointer took place . Then using for loop we arrange the elements into an array.

Program to explain call by reference

Call by reference means that object or data variable is called by introducing a reference variable . We consider any variable to make the reference of existing variables. Here in call by reference swapping of numbers takes place.

Program to explain dynamic initialization of a variable

Dynamic initialization of a variable means introducing variable at run time. Just before executing the program we initialize that respective variable . Here in this program 'a' is initialized just before the end of the program.

Program to explain sorting of the elements of an array.

Firstly array means collection of elements of same data type stored in a continuous memory allocation. Sorting of the elements of an array means arranging the array elements in ascending or descending order.

Program to explain 1-D array implementing new and delete operator.

Here we are introducing two special operators in 1-dimensional array. They are new and delete. Here new is used to allocate space for an object. Delete is used for freeing the space which was previously allocated by new operator.