;

Thursday, 23 April 2015

Ploymorphism

Ploymorphism
the word Ploymorphism is a combination of two words poly and morphism. poly means
many and morphism means form. In object oriented programming Ploymorphism is the ability
of objects of different types of respond to functions of the same name. The user does not have to know the exact type of the object in advance. The behavior of the object
can be implemented by using virtual functions. A pointer can also refer to an object of a class. The member of an object can be accessed through pointers by using the symbols. The symbols
is known as member access operator. An array can store same types of data and an array of pointer is
also can be stored memory addresses of the object of same clases user to . It allows the user to
create a large number of objects in memory .

Pointers and inheritance
Pointers have very important capability of storing the addresses of different objects
A pointer can be store the address of object whose type is same as the type of pointer
. It can be be also store the address of any object that belongs to any child class of the class of pointer. Suppose there are three classes A,B and also C.The class A is a parent class wheres B and C
are child classes. A pointer of class A can store the addresses all objects of A as well as B and C.

The Type of pointer does not change when a pointer of parent class refers to an object
of child class. That is why, the pointer always execute the member functions of parent class
even if refers to a child object in the memory.

Virtual Functions
It means existing effects but not in realty. A type of function is that appears to exist in some part
of a program but does not exist really is called Virtual function. It Also used to important
functions.

Early Binding
 The assignment of types to variables and expression at compilition time is known as
Early binding. It is also called static binding. The early binding occurs
when everything required to call a function is known at compile time. Early binding enables the computer know exactly witch function will be called when a certain statement is executed.

When a program is compiled, the compiler checks the functions calls and decides which function is
to be executed. This process takes place during compilation process in normal programs with functions.




Arrays

Arrays
An array is a group of consecutive memory locations with same name and type. Simple
variable is a single memory location with a unique name and a type. But an array is a collection of different adjacent memory locations. all these memory locations have one collective
name and type. the memory locations in the array are known as elements of array. The total number
of elements in the array is called its length.
Each elements in the array is accessed with references to its positions of location in the array. This
positions is called index or subscript.Each elements in the array has a unique index. The index
of first element is  0 and the index of last is element length is -1. The Value
the index written in brackets along with the name of array.
Arrays are used to store a large amount of similar kind of data. Suppose the user wants
to store the marks of 100 students and declares 100 variables. It is time consuming process to
use the these variables individually. This process can be simplified by using array. An array is
of 100 elements can be declared to store these values instead of 100 individual variables.

Array initializations
The process of assigning values to array elements at the time of array declaration is called
array initialization. This process provides a list of initial values of array elements. The value
are separated with commas and enclosed within braces. there must be at least one initial
value between braces. A syntax errors occurs if the value in braces are more than length of array
. So if the number of initial values is less than the array sizes the remaining array elements
are initialized to zero.

Declaring one dimensional arrays
A type of array in which all elements are arranged in the form of list is known as
on dimensional array. It is also called single dimensional array or linear list. It consists
of one column or one row. The process of specifying array name length and data type is called
array declaration.

Loops

A type of control structure that repeats a statements is known as looping structure. It is also known as iterative or repetitive structure. In sequential structure all statements are executed once.on the other hand Conditional structure may execute or skip a statement on the basis of some given condition.In some situations it is required to repeat s statement or number of statements For a Special number
of Times. Looping Structures are used for this purpose. There are different types of loops available in
C++.

Counter Controlled Loops 
This type of loop depends on the value of a variable known as counter variable. The value
of counter variable is incremented or decremented each time the body of the loop is executed
. So This Loop terminates when the value of counter variable reaches a particular value. The
Number of iterations of counter controlled loop is in advance.The iteration of this loop depends on the terminating condition,increment or decrement value.

Sentinel Controlled Loops
This type of loop depends on special value known as sentinel value. The Loop terminates
when the sentinel value is encountered. These Types of loops are also known as conditional
loops. A Loop may execute while the value of a variable is not here. The Number of iteration
of sentinel controlled loop is unknown. It depends on the input from the users. Suppose the
 sentinel value to terminates a loop is 1 if the users enter 1 in first iteration,the loop will
execute only once. But if the user enter after entering many other values,the number of iterations
will very accordingly. A sentinel value is commonly used with while and Do-while loop.

While Loop
This is the simplest loop of C++ language. This Loop executes one or more statements while the
given condition remains true. It is useful when the number of iterations is  not known in advance.First of All the condition is evaluated. If it is true,the control enters the body of the loop and executes
all statements in the body. After executing the statements it again moves to the start of the loop
and evaluates the condition again. This process continues as long as the condition remains true.
When the condition becomes false/the conditions remains true,the loop never ends. A loop that
has not end points is known as an infinite loop.