Wednesday, 18 November 2015

library




Library is the collection of sub programs (functions) used to develop other programs and software.
Libraries are not independent program rather they are helper code (statements) used in other independent programs. The C++ library of functions stores functions of some category (mathematical function,string function,etc) under separate files known as header files.

So the library contains standard functions which make a program easy to understand.

Header files provide function prototype,definition for library functions EX. stdio.h, conio.h,math.h, string.h, iostream.h.

Each and every string is ended with \0(\zero) & is also called nul character.

Selection


 it is just like your multiple choice questions in exam in which most appropriate option you choose .likewise in c++ we are developing a suitable program for user to choose his own way to operate that program .selection means execution of statement depending upon a condition .if condition evaluates true set of instruction will be executed and if condition evaluates false another set of instructions will be executed .









call by value


1 In call by value when a function is called the value opf actual parameter are passed to formakl parameter
2 The change in formal parameter in the functiopn will not affect the actual parameter in the calling function.
3The execution of program is slower.
4 Memory location occupied by formal and actual parameter are different.

Inheritense



Inheritense is related with the concept of reusavbility. We alwayse feel good when we reuse somwthing.
In inheritence the class can share thew properties of another class withought  rewriting the same codeor properties.
Ex :- Let us take an instance of automobile class.It contains attributes like engine, tyures, fuel, seats, chasies, etc. Now these can be instance of other classes car, bike having the properties engine, fueal seets with some extra properties , but the properties of automobile class will be used in these classes withoughht rewriting  them again in these  class .
There are five types of inheriternce :-
1 single inheritence .
2 Multi level inheritence .
3 Multiple i9nhertitence .
4 Herarchical inheritence .
5 Hybride inheritence.

Derived class can be acces only protected and publick properties of base class as publically , protectly, privatly

polymorphism





It is the third essential feature of OOPs after data abtraction and inheritence we can define  polymorphysm in one sentence - one interface  many formn.
Polymorphysm is the ability to define many different operation using the same name . Literally it means many forms and  is taken from the greek polos (many) and morpye (form) meaans that ability to take more than  one form.
An operation may exhibit different behaviours in different instancess (part). The behaviour depend upon the type of data used in the operation.
We can  explain polymorphysm by the phrase :-  
                                                                                 "One interface multiuple methods"
It helps to reduce complexity by ballowing the same interface for different clas of action.

It is compilers job to select the specific  action (method) as it applies to each situation .

It also improves code readability as well as the creation of extensible programs. In general way a single function name can be used to handle diffderernt no. and different types of arguments.

We can also use (area) when we are going to calculate area of different shapes.

call by refrence


 1 In call by refrence when a functionis called the address of actual parameters are pasased to the formal parameters.
 2 The change in formal parameters in the function will affect the actual parameter in the calling function

Functions


A function is a block of codes  that has a name, return type and no. and type of parameter list. Every function is used to perform specific task and it can be executed at the different locations and in a C and C++ program as required .
A function is a self contained block of statements that perform a particular task. The name of the function must be unique.

Types of function:-

There are two types of function :-

        1 Library function (built in) function.
        2 User defined function.

Function is a type of  parameter which contains function and character(like no. , and type of   parameters.


Types of function :-


1 Built in function :-

 These function are part of the compiler package. These are parts of standard library made available by the compilers. For example; exit(), sqrt() , pow(), etc. are library functions (or built -in functions).
(read more)

2 User defined function:-  

 The user defined function are created by you ,i.e., the programmer. These function are created as per  requirements of your program.
(read more)

Function Prototype:-

A function prototype is  a declaration of the function that tells the program about the types of the L value returned by the function and the no. and the type of arguments It is one very useful factor of C++ function.
A declaration introduces a (function) name to the program whereas a definition tells the program what the function is doing and how it is doing.
The following are the declaration or we can say function prototype.
int absval(int a);
int ged (int n, int z);
A definition is automatically also a declaration.
Therefore we can say that a function prototype has following parts:-
1 Return type.
2 Name of the function.
3 Argument list.
Need for prototype:- Function prototyping enables a compiler to carefully compare each use of the function with the prototype to determine whether the function is involved properly i.e.the no. and type of argument are compared and any wrong number or type or the argument is reported. Thus correcting such problem is easy as C++ can straightly point to the error.
A function declaration can skip the argument names but a function definition cannot.
In a function prototype the name of the argument are optional:Ex:-
float volume (int a,float b, float c);
float area (float,float);      // variable names are optional.
Use of void - Void is used as the return type for functions that do not return a value.Thus a function that does not return a value is declared as follows :
void function-name (parameter list):
A function that does not require any parameter (i.e., it has an empty argument list ), can be declared as follows :-

type function name(void);

A function prototype is not needed when the function definition appears its calling function.
Possible function styles:
1 void function with no argument - This style of function simply perform an independent task. It does not send or receive any parameter and it does return any value.
2 Void function with some argument- This style of function does receive some arguments (parameters) but does not return a value.
3 void function with no arguments - This style of function takes some arguments and does not return a value.