Knowledge in C++

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.

OOPS with C++-Data Abstraction and Data Encapsulation

this PDf is all about main concepts of OOps with C++ programming language. Objects Classes Data Abstraction and Data Encapsulation Inheritance Polymorphism Dynamic Binding Message Passing .

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.

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.

Program to explain factorial of a given number using recursion.

Let us know the meaning of recursion first. Recursion means the third digit is equal to the sum of first two digits. That is called recursion. It may be addition , multiplication. Factorial means product of all the numbers upto the given number.