SlideShare ist ein Scribd-Unternehmen logo
1 von 147
Downloaden Sie, um offline zu lesen
C++ (Object Oriented Programming),[object Object],Depending  on the instruction style programming are mainly classified into 2 types.,[object Object],Structure Oriented programming:   In this there are some standard principles followed by the programmer from 1960’s . The best example for structure oriented programming’s and ‘C’,pascal,…..etc.  ,[object Object], The principle’s for S.O.P is .,[object Object],[object Object],.  Top-down approach : In S.O.P there is a top level module which control’s all the sub-module.,[object Object],Ex:    main() is a top level  function  which control’s all the sub functions.,[object Object],[object Object],[object Object],[object Object],[object Object]
Advantages Of OOP  :,[object Object], OOP  provides many advantages to the programmer and the user. This Technology solves many problems related to software related to software  development, provides improved quality, and also low-cost software .,[object Object],Object –oriented programs can  be Comfortably Upgraded .,[object Object],Using Inheritence,redundant program codes can be eliminated and the use of previously defined classes may be continued .,[object Object],The technology of data hiding facilitates the programmer to design and develop safe  programs that do not disturb code in other parts of the program .,[object Object],The encapsulation  feature provided by OOP language allows programmer to define the class with many functions and characteristics and only few functions are exposed to the user .,[object Object],All OOP Lang's  can create extended  and  reusable parts of programs .,[object Object]
Relation between data  and  member function  in OOP,[object Object],OOP pays more importance to data than to function.,[object Object],Programs are divided into classes and their  member functions.,[object Object],New data items and functions can be comfortably added whenever essential.,[object Object],Data is private and prevented from accessing external functions.,[object Object],Objects can communicate with each other through functions.,[object Object],Object  A                      Object  B                 Object  C ,[object Object],Data varible,[object Object],Data variables,[object Object],Data varibles,[object Object],Data varible,[object Object],Member   Fn,[object Object],Member   Fn,[object Object],Data varible,[object Object],Data  varible,[object Object],Data varible,[object Object],Member   Fn,[object Object],Member   Fn,[object Object],Member   Fn,[object Object]
History of C++ :,[object Object],                                  C++  is  an Object –oriented Programming language and is Considered to be an extension of C. Bjarne Stroustrup  at  AT&T Bell Laboratories, Murray Hill, New Jersey(U.S.A) Developed it in the early eighties of twentieth century .In the initial name of this object-oriented program’s is C with Classes. Later on it was renamedas C++ (Incremented version of C-Language).,[object Object],I.O Statements :,[object Object],                            C++ Doesn’t  provide ,output statement  instead operator is has two stream object’s  i.e. . , Cout ,Cin  for input , output operator.,[object Object],  Syntax :,[object Object],cout<<“ message”;,[object Object],                             insertion operator,[object Object],    Example :     cout<<“hi”;,[object Object],                                 This stream object is defined for consoler out put  devices keyword using this we can print the constraction message an varible  as this screen.,[object Object],                            Syntax :   cin>>”varibles”;,[object Object],Extraction operator ,[object Object],      Example :   cin>>a>>b;,[object Object]
This stream object is defined for standard input  devices keywords. Using this we can read the variable  values from the keyboard. ,[object Object],    The above i.o stream’s are defined  as ,[object Object],#include<iostream.h>,[object Object],    A small example  for iostream function’s.,[object Object],     #include<iostream.h>,[object Object],     #include<conio.h>,[object Object],       void main(),[object Object],   {,[object Object],      int  a , b , c;,[object Object],        clrscr();,[object Object],  cout<<“Enter the value’s of a , b  :  ”;,[object Object],  cin>>a>>b;,[object Object],     c=a+b;,[object Object],     cout<<“The sum of two value’s is : ”<<c;,[object Object],                getch();,[object Object],      },[object Object],Output :,[object Object],                 Enter the value’s of a , b  :  5  5,[object Object],                    The Sum of two value’s Is : 10,[object Object],  Some other per-defined in C++ Streams   i.e..,,[object Object],clog :    A fully buffered version of cerr(no C equivalent).It Controls error messages that are passed from buffer to the standard error device.,[object Object],cerr : Standard error output, usually screen , corresponding to stderr in C. It controls the unbuffered  output  data. It catches  the error and passes  to  standard  error device monitor.,[object Object]
A program to display message  using  pre-defined objects.,[object Object],           #include<iostream.h>,[object Object],               #include<conio.h>,[object Object],                 void main(),[object Object],              {,[object Object],                   clrscr();,[object Object],                cout<<“ SRAVAN KUMAR  : ”; ,[object Object],cerr<<“ SRAVAN KUMAR : ”;,[object Object],                clog<<“ SRAVAN KUMAR :”; ,[object Object],                     } ,[object Object], output :,[object Object],SRAVAN KUMAR,[object Object],SRAVAN KUMAR,[object Object],SRAVAN KUMAR,[object Object],STREAM CLASSES :,[object Object],          C++ streams are based on class and object  theory . C++ has a  number o  of  stream classes that are used to work  with console and file  operations.  These  classes are known  as  stream classes. All these  classes are declared  in the header file  “IOStream.h”. The file  iostream.h must be  included in the program if we are using functions of these classes.,[object Object],                  The classes  istream and ostream are derived classes of base class IOS.,[object Object]
This is Stream classes figure.,[object Object],IOS,[object Object],istream,[object Object],ostream,[object Object],streambuf,[object Object],iostream,[object Object],file buffer,[object Object],Types of Tokens :,[object Object],The compiler identifies them as tokens. Tokens are classified in the following types.,[object Object],Keywords                 2) Variables                 3)  Constants,[object Object],4) Special Character        5) Operator.,[object Object],Keywords,[object Object],Varibles,[object Object],Operators,[object Object],Tokens,[object Object],Constants,[object Object],Special Characters,[object Object]
Additional  C++  keyword’s,[object Object],Asm       private     public     protected      catch      class     delete     friend       inline   ,[object Object],New      operator   template      this            throw     try          virtual     ,[object Object],Referencing  Operator( &) :,[object Object],                The referencing operator is used  to define  referencing variable. A reference variable prepares an  alternative (alias) name for previously defined  variable.,[object Object],  Syntax :  ,[object Object],                  data-type  &reference varible name=varible name.,[object Object],  Example:,[object Object],                 int qty=10;,[object Object],                 int &qt=qty;,[object Object],Principles  for  declaring  reference variable :,[object Object],  1)  A reference variable  should be initialized.,[object Object], 2)  Once  a reference variable  is declared, it  should not refer to any  other  variable. Once  the actual    variable  and reference variable  are connected they are tied jointly  congenitally.,[object Object], 3) The reference variable can be created  referring to pointer variable.,[object Object],       ex:   char  *h=“C++”;,[object Object],4)  A variable can contains various references. Modifying the value  of one of them results in a change in all others.,[object Object],5) Array of references is not allowed.,[object Object]
Example  : ,[object Object],                #include<iostream.h>,[object Object],                     void main(),[object Object],                  {,[object Object],                        int a=100;,[object Object],                      int &k=a;,[object Object],                         k=45;,[object Object],                       cout<<“ a =”<<a;                       cout<<“ k =”<<k;                         },[object Object],Example 2: ,[object Object],                     #include<iostream.h>,[object Object],                    #include<stdio.h>,[object Object],                     #include<conio.h>,[object Object],                         void main(),[object Object],                      {,[object Object],                           clrscr();,[object Object],                           int f=10;,[object Object],                           int  &r=f;,[object Object],                        printf(“ The location of -> f   and    r->location   is    :   ”);,[object Object],                        printf(“  ------------ -  %d    %u    %d    %u ”, r , &r , f , &f );,[object Object],                          r++;,[object Object],                      printf(“  %d     %u   %d    %u”, r , &r , f , &f  );,[object Object],                        f--;,[object Object], printf(“  %d     %u   %d    %u”, r , &r , f , &f  );,[object Object],                          getch();,[object Object],                       }                             ,[object Object]
Scope Access Operator :,[object Object],                            like C, the variables declared in C++ programs are totally different form other  languages. We can use the same variable names in the C++   program in separate blocks. The declaration of the same variable refers to different memory locations. When  we declare a variable it is  available only to specific part or block of the program . The remaining block or other function cannot access the variable . The area or block of the  C++ program from where the variable can be accessed is known as the scope of variables. ,[object Object],                          The scope access (or resolution ) operator :: (two semicolons) allows a programmer to access a  global(or file duration) name even  if it is hidden by a local re-declaration of that time.,[object Object],  Example :,[object Object],                         #include<iostream.h>,[object Object],                        #include<conio.h>,[object Object],                           int a=10;,[object Object],                         void main(),[object Object],                         {,[object Object],                            clrscr();,[object Object],                            int a=20;,[object Object],                          cout<<“  The global value of a is  : ”<<: : a;,[object Object],                           cout<<endl<<“The local value is a = : ”<<a;,[object Object],                               getch();,[object Object],                       },[object Object],Comma Operator :,[object Object],                        In C ,every  statement of the program is terminated by semi-colon(;). It is also applicable in C++ and  in addition, C++ allows us to terminate using comma operator after  satisfying  the following rules.,[object Object],[object Object],[object Object]
 C++ permits declaration of variables at any place  in program but such declaration is not allowed in between the statements terminated by comma operator .The initialization of previously declared  variables can  be done.
   The last statement of the program must be terminated by semi-colon.   Example  :,[object Object],                            #include<iostream.h> ,[object Object],                             #include<conio.h> ,[object Object],                             void main( ),[object Object],                           {,[object Object],                              clrscr(),,[object Object],                               cout<<“ This is Comma operator  : ”,,[object Object],                               cout<<endl;,[object Object],                                  },[object Object],Example 2:,[object Object],                        #include<iostream.h>,[object Object],                        #include<conio.h>,[object Object],                         void  main( ),[object Object],                       {,[object Object],                           int x;,[object Object],                              clrscr(),,[object Object],                               x=10,,[object Object],                              cout<<endl<<“ X  =”<<x,,[object Object],                             cout<<endl;,[object Object],                              }      ,[object Object]
Function’s in C++ :,[object Object],One of the features of C/C++ language is that a large sized  program can be divided into smaller ones. The smaller programs can be written in the form of functions. The process of dividing a large program into any tiny and handy sub-programs and manipulating them independently is known  as Modular programming. This technique is similar to divide-and-conquer technique. Dividing a large program into smaller functions provides advantages to the programmer. The testing and debugging of a program with functions becomes easier. A function can be called repeatedly based on the application and thus the size of the program can be reduced. The message passing between a caller (calling function ) and  callee (called function) takes places using  arguments. The concept of modular approach of C++ is obtained from function,[object Object], The advantages of function :,[object Object],[object Object]
  Reduction  in program size.
  Code duplication is avoided.
  Code reusability is provided.
  Functions can be called respectively.
  A set of functions can be used to form Libraries.  Void main( ),[object Object],{,[object Object],   statement 1;,[object Object],    statement 2;,[object Object],    statement 3;,[object Object],    statement 4;,[object Object],    statement 5;,[object Object],       -----------,[object Object],       -----------,[object Object],    statement n; ,[object Object],    }     ,[object Object],Large Program,[object Object],This is with out Functions diagram,[object Object]
Like C,C++ supports two types of functions. They are (1) Library functions, and (2) User defined functions. The library functions can be used in any program by including respective header files.The header files must be included using # include preprocessor directive. The programmer can also define and use his/her own functions for performing some specific tasks. such functions  are called as user-defined functions. The user-defined functions are those that are defined in a class.They are called as member functions.,[object Object],caller,[object Object],Void main(),[object Object],{  ,[object Object],   statement 1;,[object Object],   statement  2;,[object Object],     sum();,[object Object],   statement 3;,[object Object],   statement 4;,[object Object],     sum();,[object Object],    statement 5;,[object Object],    statement 6;,[object Object],    },[object Object],Sum(),[object Object],{,[object Object],   statement 1;,[object Object],    statement 2;,[object Object],    statement 3;,[object Object],  },[object Object],This diagram is Program with functions,[object Object]
The main() function in C and C++   :,[object Object],Main() in C++,[object Object],Main() in C,[object Object],   int main( ),[object Object],    {,[object Object],           stmt 1;,[object Object],            stmt 2;,[object Object],               return 0;,[object Object],           },[object Object],    main( ),[object Object],    {,[object Object],           stmt 1;,[object Object],            stmt 2;,[object Object],           },[object Object],Return type is specified.,[object Object],The return  stmt is used.,[object Object],Can be declared as void. If declared void, no need of return statement.,[object Object],No return type is specified, and not necessary.,[object Object],No  return  statement is used.,[object Object],Can be declared as void.,[object Object],In C++ the function main() always returns integer value to operating system by default. The return value of the function  main() is used by the operating system to check whether the program is executed successfully or not. If  the returned  value is zero (0),it means that the program is executed successfully. A non-zero  value indicates that the program execution was unsuccessful.  The statement return 0 indicates that the program execution is successful. The return statement is used to return type value. If there is no return statement, compiler displays a  warning message “Function should return a value ”.Every function including main() by default  returns an integer value ,hence the keyword int before function main() is not Compulsory. In C there is no return  type  to function main().,[object Object]
Parts of Function :,[object Object],1) Function prototype declaration.,[object Object],     2) Definition of a function (function declarator)     3) Function call,[object Object],     4) Actual and Formal arguments.,[object Object],     5) The return Statement.,[object Object],Function prototype  :  we use many built-in functions. The prototypes of these functions are given in the respective header files. We include them using # include directive. In C++ while defining user-defined functions., it is unavoidable to declare its prototype. A prototype statement helps the complier to check the return and argument types of the function. A function prototype declaration consists of the function return type ,name,and argument list. I tells the complier (a) the name of the function (b) the type of value returned, and the type and number of arguments.,[object Object],                                when the programmer defines the function, the definition of function must be like its prototype declaration. If the programmer makes amistake,the compiler flags an error message. The function prototype declaration statement is always terminated with semi-colon.,[object Object], Void main( ),[object Object],{,[object Object],   float sum(float,int );,[object Object],     float x,y=9.5;,[object Object],    x=sum(y,z);,[object Object],  },[object Object],  float sum(float j,int k),[object Object],      {,[object Object],     return (j+k);,[object Object],},[object Object],     }}}},[object Object],Function Prototype,[object Object],Actual Arguments,[object Object],Function call,[object Object],Formal Arguments,[object Object],Function Declarator,[object Object],Function Body,[object Object],Return Statement,[object Object]
Function Definition :The first line is called function declarator and is followed by function body. The block of statements followed declarator is called as function definition. The declarator and function prototype declaration should match each other. The function body is enclosed with curly braces. The function can be defined anywhere. ,[object Object],Function call : A function is a latent body.it gets activated only when a call to function is invoked.A function must be called by its name.,[object Object],Actual & Formal Arguments :The argument declared in caller function and given in the function call are called as actual arguments. The arguments declared in the function declarator are known as formal arguments.,[object Object],Void main( ),[object Object],  {,[object Object],              x=sum ( y , z );,[object Object],     },[object Object],     float sum( float j,float k),[object Object],           {,[object Object],              return (j+k);,[object Object],               },[object Object],Actual argument,[object Object],Formal Argument,[object Object],The return Statement :  The return Statement is used to return value to the caller function.The returns statement returns only one value at a time.,[object Object],      syntax:,[object Object],                     return (var_name);,[object Object],                              (or),[object Object],                        return var_name; ,[object Object]
Example :,[object Object],                   #include<iostream.h>,[object Object],                   #include<conio.h>,[object Object],                       int main(),[object Object],                         {,[object Object],                             clrscr();,[object Object],                               float sum(int , float );   //fun prototype,[object Object],                                 int  a=20;,[object Object],                                  float s,b=2.4;,[object Object],                                    s=sum(a,b); ,[object Object],                                   cout<<“Sum =”<<s; ,[object Object],                                      return 0;,[object Object],                                   },[object Object],                              float sum(int x,float y) ,[object Object],                                 {,[object Object],                                     return (x+y);,[object Object],                                     }  ,[object Object],Ex 2: ,[object Object],#include<Iostream.h>,[object Object],                #include<conio.h>,[object Object],                     void main(),[object Object],                      {,[object Object],                         clrscr();,[object Object],                           void show(void);,[object Object],                             show();,[object Object],                            },[object Object],                             void show(),[object Object],                           { ,[object Object],                          cout<<“ It is show function : ”; ,[object Object],                          },[object Object],Passing Arguments :,[object Object],The main objective of passing argument to function is message passing. The message passing is also known as communication between two functions i.e.., between caller and callee functions.,[object Object],      a) Call by value  (pass by value).,[object Object],      b) Call by reference (pas by reference).,[object Object],1) Pass by value :value of actual argument is passed to the  formal function argument and operation is done on the formal arguments. Any change in the formal argument does not effect the actual argument because formal arguments are photocopy  of actual arguments. Hence when function is called by call by value method. ,[object Object],2) Pass by reference :C passes arguments by value and address.C++ it is pass arguments b y value ,address and  reference . C++ reference types,declared with & operator are nearly identical but not exactly same to pointer types.They declare aliases for object varibles and allow the programmer to pass arguments by reference to functions.The declarator( &) can be used to declare reference outside functions.,[object Object]
Ex ample for (To pass the value of variable  by value,reference,and address and display the result) :,[object Object],#include<Iostream.h>,[object Object],#include<conio.h>,[object Object],#include<process.h>,[object Object], void main(),[object Object], {,[object Object],    void funA(int  s);,[object Object],    void  funB(int  &);,[object Object],    void  funC(int  *);,[object Object],      int s=4;,[object Object],        funA(s);,[object Object],   cout<<“ Value of s =”<<s;,[object Object],   cout<<“Address of s  :”<<unsigned(&s);,[object Object],        funB(s);,[object Object],  cout<<“ Value of s =”<<s;,[object Object],   cout<<“Address of s  :”<<unsigned(&s);    ,[object Object],                funC(&s);                                     ,[object Object], cout<<“ Value of s =”<<s;,[object Object],   cout<<“Address of s  :”<<unsigned(&s);,[object Object],                },[object Object],       void  funA(int  i),[object Object],           {,[object Object],                i++;,[object Object],                 },[object Object],          void  funB(int  &k),[object Object],            {    ,[object Object],                   k++;                    },[object Object],     void funC(int  *j),[object Object],           {,[object Object],               ++*j;,[object Object],              },[object Object]
Default Arguments :Function takes a collection of parameters when the user doesn’t sent any argument then the function it takes the default values to the missed arguments.,[object Object],Syntax : <return type >  < Func_name > (<arg1>=<default>,…………),[object Object],                        { ,[object Object],                           -----------------------,[object Object],                           -----------------------,[object Object],                                 },[object Object],  The missing argument of parameter always form right to left.,[object Object],               Ex:       #include<iostream.h>,[object Object],                             void sum(int  a=0,int  b=0,int  c=0,int  d=0),[object Object],                               {,[object Object],                                    cout<<“ Sum is : ”<<a+b+c+d;,[object Object],                                          },[object Object],                                   void main( ),[object Object],                                 {,[object Object],                                     sum(1,2,3,4);,[object Object],                                     sum(5,6,7);,[object Object],                                     sum(9);,[object Object],                                     },[object Object]
Ex  2:   #include<IOSTREAM.H>,[object Object],                 #include<conio.h>,[object Object],int main( ),[object Object],               {,[object Object],                    clrscr();,[object Object],                   int  sum(int a,int b=1,int c=2,int d=4);  //fun prototype,[object Object],                    int a=2;,[object Object],                     int b=3;,[object Object],                      int c=4;,[object Object],                       int d=6;,[object Object],                cout<<“ Sum = ”<<sum(a,b,c,d);,[object Object],               cout<<“ Sum = ”<<sum(a,b,c);,[object Object],                cout<<“ Sum = ”<<sum(a,d);,[object Object],               cout<<“ Sum = ”<<sum(b,c,d);,[object Object],                       return 0;,[object Object],                  },[object Object],              sum(int j,int k,int l,int m),[object Object],              {,[object Object],                    return (j+k+l+m);,[object Object],                    },[object Object]
INLINE Functions: The C++ provides a mechanism called inline function.When a function is declared as inline, the compiler copies the code of the function in the calling function i.e.., function body is inserted in place of function call during compilation.passing of control between  caller and callee funcitons is avoided. If the function is very large,in such  a case  inline function is not  used  because the compiler copies the contents in the called function that reduces the program execution speed. The inline  function is mostly useful  when  calling function is small.It is advisable to use the inline fucntion for  only small function. ,[object Object],                      inline mechanism increases execution performance in terms of speed .The overhead of repetitive function calls and returning  values are removed.the on the other hand the program using inline functions needs more memory  space since the inline functions are copied at every point where the function is invoked.,[object Object],                       For defining an inline- function, the inline keyword is preceded by the function name.,[object Object],                 syntax :   ,[object Object],                                  inline  function_ name( ),[object Object],                                         {,[object Object],                                            statement  1;,[object Object],                                            statement  2; ,[object Object],                                               },[object Object],Following are some situations where inline function may not work :,[object Object],   1) The function should not be recursive.,[object Object],   2) Function should not contain static variables.,[object Object],   3) Function containing control structure statements such as switch, if ,for loop etc.,[object Object],   4) The function main( ) cannot work as inline.     ,[object Object],                 The inline functions are similar to macros of C . The main limitation with macros is that they are not functions and errors are not checked at the time of compilation. The function offers better type testing and do not contain side effects as present in macros.,[object Object]
Example : #include<iostream.h>,[object Object],              #include<conio.h>,[object Object],              #define SQUARE(v)   v*v,[object Object],                inline float square(float  j),[object Object],                  {,[object Object],                      return  (j*j);,[object Object],                      },[object Object],                 void main( ),[object Object],                  {,[object Object],                     clrscr();,[object Object],                    int  p=3,q=4,r,s;,[object Object],                     r=SQUARE(++p);,[object Object],                     s=square(++q);,[object Object],                      cout<<“ r =”<<r<<“”<< “s= “<<s; ,[object Object],                    },[object Object]
Function over loading :   In C++ use the same function name for a number of  times for different intensions.Defining multiple functions with same name known as function overloading or function polymorphism. Polymorphism means one function having many forms.The overloaded function must be different in its argument  list and with different data types.,[object Object],     Example:    # include <iostream.h> ,[object Object],                      # include<conio.h>,[object Object],                     int sqr(int );,[object Object],                     float sqr( float );,[object Object],                         main( ),[object Object],                       {,[object Object],                        clrscr();,[object Object],                    int a=4;,[object Object],                        float b=6.4;,[object Object],                    cout<<“ Square = ”<<sqr(a) <<endl;,[object Object],                   cout<<“ Square = ”<<sqr(b) <<endl;,[object Object],                          return 0;,[object Object],                        },[object Object],                    int sqr(int s),[object Object],                     {,[object Object],                         return (s*s);,[object Object],                              },[object Object],                     float sqr(float  j),[object Object],                      {,[object Object],                         return  (j*j);,[object Object],                             },[object Object]
Object :objects are primary run- time entities in an object-oriented programming.,[object Object],Class :A class is grouping of objects having identical properties , common, behavior , and shared relationship.,[object Object],Method :An operation required for an  object or entity or entity  when coded in a class is called a method.,[object Object],Syntax  for class :,[object Object],      class <name of the class>,[object Object],       {,[object Object],           <Access specifier > :,[object Object],                              Data members;,[object Object],                              -------------------,[object Object],               <Access specifier > :,[object Object],                             Member Function;,[object Object],                     };,[object Object],The Object can declare as :,[object Object],                            [object name] [operator]  [member name],[object Object],Ex :    a . show();,[object Object],Access Specifier :  it is used to provide the data hiding from other parts of the programm. In C++ there are 3 types of specifier.,[object Object],     1) private.,[object Object],     2) protected.,[object Object],     3)  public .,[object Object],Private: This specifier is used for only with in the class accessing .i.e.., data members & member function’s are Should be a private type. It is accessing only that class.it not acesspected out of the class. And also the main function cannot access the private type.,[object Object]
For Example :,[object Object],             # include <iostream.h>,[object Object],            #include<conio.h>,[object Object],             class xyz,[object Object],               {,[object Object],                 int a,b;,[object Object],                    };,[object Object],                   void main(),[object Object],                  {,[object Object],                        clrscr();,[object Object],                          class xyz  obj;,[object Object],                          obj.a=1;,[object Object],                          obj.b=2;,[object Object],                             getch();,[object Object],                     } ,[object Object]
Protected :  This access specifier is used for the inherited of sub class. I.e.., inheritence relation.The property sholud contain the super class .it is accessed into the sub class.,[object Object],          A                                   B,[object Object],Public :This is used any where it can accessed .if u declare the specifier is data member & member function of public.The main function should be accessed.,[object Object],          A               B               C                  D               E,[object Object],# include<iostream.h>,[object Object],# Include<conio.h>,[object Object],Class  XYZ,[object Object],{,[object Object],   private :,[object Object],         int a;,[object Object],    protected :,[object Object],          int b;,[object Object],      public :,[object Object],         int c;,[object Object],         };,[object Object]
void main( ),[object Object],{,[object Object],   clrscr();,[object Object],    class  XYZ   x;,[object Object],     x.a=10;,[object Object],    cout<<endl;,[object Object],     x.b=20;,[object Object],      cout<<endl;,[object Object],      x.c=30;,[object Object],      getch( );,[object Object],},[object Object],Class name,[object Object],object,[object Object],class,[object Object],Static member variables :  In the earlier that each object has its separate set of data member variables in memory. The member functions are created only once and all objects share the functions. No separate copy of function of each object is created in the memory like data member variables. ,[object Object],                         It is possible to create common member variables like function  using  the static keyword. ,[object Object],Once a data member variable is declared  as static,only one copy of that member is created for the whole class.The static is a keyword  used to preserve value of variable. When variable is declared as  static it is initialized to zero. A static function or data element is only  recognized inside the scope of the present class.    ,[object Object]
Syntax :   Static <variable Declaration >;,[object Object],                Static < Function declaration >;,[object Object],                          if a local variable Is declared with static keyword, it preserves the last value of the variable.A static data item is helpful when all the objects of the class share a common data.The static  data variable is accessible with in the class ,but its value remains in the memory throughout the whole program. ,[object Object],Object A,[object Object],Object B,[object Object],Variable 1,[object Object],Variable 1,[object Object],Variable 2,[object Object],Variable 2,[object Object],Variable n,[object Object],Variable n,[object Object],Static  Variable,[object Object],Object C,[object Object],Object D,[object Object],Variable 1,[object Object],Variable 1,[object Object],Variable 2,[object Object],Variable 2,[object Object],Variable n,[object Object],Variable n,[object Object]
Example :   ,[object Object],     # include <iostream.h >,[object Object],    # include <conio.h>,[object Object],  class   number{,[object Object],     static int c;,[object Object],     public :,[object Object],            void count(),[object Object],      {,[object Object],              ++c;,[object Object],               cout<<“  c= ”<<c;,[object Object],           } ,[object Object],     };,[object Object],Int number :: c=0;  //  initialization of static member variables,[object Object],    void  main(),[object Object],{,[object Object],       number a,b,c;,[object Object],            clrscr();,[object Object],      a.count();  b.count( ); c.count();,[object Object],                 return 0;,[object Object],},[object Object]
Constructors   And  Destructors,[object Object],We defined a separate member function  for  reading input values for data members. Using  object ,member function is invoked  and data members are initialized. The  programmer needs to call the function. C++  provides  a pair  of  in-built special member functions called Constructor and Destructor.  The Constructor constructs the objects and destructor destroys the objects .The compiler automatically executes these functions. The programmer  does not need to make any effort  for invoking these functions.,[object Object],                        The C++ run-time arrangement takes  care of execution  of constructors and destructors. When an object is created ,constructor is executed. The programmer can  pass values  to the  constructor  to initialize member variables  with different values. The destructor destroys the object. The destructor is executed at the end of the function when objects are  of no use or goes out of scope.,[object Object],                       Constructors and destructors are special member function.,[object Object]
Characteristics of Constructor :,[object Object],Constructor has the same name as that of the class it belongs.,[object Object],Constructor is executed when an object is declared.,[object Object],Constructors have neither return value nor void.,[object Object],Though constructors are executed implicitly, they  can be invoked explicitly.,[object Object],Constructor can have default and can be overloaded.,[object Object],The constructor without arguments is called as default Constructor.,[object Object],Example  :,[object Object],                       #include< iostream.h >,[object Object],                        class num,[object Object],                       {,[object Object],                           private :,[object Object],                              int a,b,c;,[object Object],                                public :,[object Object],                                   num();// declaration of constructor,[object Object],                                void show(),[object Object],                             {,[object Object],                                   cout<<endl<<“ a =“<<a<<endl<<“ b=“<<b<<endl<<“ c =“<<c;,[object Object],                                   },[object Object],                          };,[object Object]
num :: num( ),[object Object], {,[object Object],    cout<<“ Constructor is called : ”;,[object Object],     a=1;,[object Object],    b=2;,[object Object],    c=3;,[object Object],    },[object Object],   void main( ),[object Object], {,[object Object],    clrscr();,[object Object],    num  x;,[object Object],    x.show();,[object Object],      },[object Object],Destructors,[object Object],Destructors are opposite to the constructor. The process of destroying the class objects created by constructors is done in destructor. preceded by a tilde(~).A destructor is automatically executed when object goes out of scope. It is also invoked when delete operator is used to free memory allocated with class pointer.,[object Object]
Characteristicsfor Destructors  :,[object Object],Like constructor, the destructor  does not have return type and even void.,[object Object],Constructor and destructor cannot be inherited, though a derived class can call the constructors and destructors of the class .,[object Object],Destructor can be virtual, but constructors cannot.,[object Object],Only one destructor can be defined in the destructor. The destructor does not have any argument.,[object Object],The destructors neither have default values nor can be overloaded.,[object Object],Turbo C++  compiler can define  constructor & destructor if they have not been explicitly defined.They are also on many cases  without explicit calls in program. Any constructor or destructor created by the compiler will be public. ,[object Object],Example ;,[object Object],                    #include<iostream.h>,[object Object],                      int c=0;,[object Object],                    class    num,[object Object],                   {,[object Object],                       public :,[object Object],                    num(),[object Object],                  {,[object Object],                       c++;,[object Object],                 cout<<“ Object created : ”<<c;,[object Object],             }         ,[object Object]
~num(),[object Object],  {,[object Object],     cout<<“ Object’s are  destroyed : ”<<c;,[object Object],      c--;,[object Object],     },[object Object],};,[object Object],  void main(),[object Object],   {,[object Object], clrscr();,[object Object],  cout<<“ main function   : ”<endl;,[object Object],    class  num  a,b;,[object Object],    cout<<“ In Block  A  ”;,[object Object],    {,[object Object],       class   num   c;,[object Object],   },[object Object],     cout<<“   Again in main  function  : ”;,[object Object],        },[object Object]
Constructor with Arguments,[object Object],Constructors initialize the member  variables with given values.It Is possible  to create constructor with arguments and such constructor are called as parameterized.,[object Object],Example :,[object Object],                      #include<iostream.h>,[object Object],                      #include<conio.h>,[object Object],                      class num,[object Object],                     {,[object Object],                       private:,[object Object],                         int a,b,c;,[object Object],                           public:,[object Object],                         num(int m,int j,int k);  // declaration of constructor with arguments,[object Object],                           void show(),[object Object],                         {,[object Object],                           cout<<“  A = ”<<a<<“  B =”<<b<<“  C =”<c;,[object Object],                              },[object Object],                           };,[object Object],                      num :: num(int m,int j,int k)  //  defination of constructor with argu,[object Object],                       {,[object Object],                        a=m;  b=j;  c=k;,[object Object],                  },[object Object]
Void  main( ),[object Object],   {,[object Object],      clrscr();,[object Object],        num x=num(1,2,3);   //explicit call,[object Object],        num  y(4,5,6);           //  implicit  call,[object Object],         x.show();,[object Object],         y.show();,[object Object],             },[object Object],Overloading constructors  :,[object Object],It is also possible to overload constructors. We declared single constructor without arguments and with all arguments. A class can contain more than one constructor. This is known as constructor overloading. All constructors are defined  with the same name as the class. All the constructors contain different number of arguments.Depanding upon number of arguments,the compiler executes appropriate constructor.,[object Object],Example :  w.a.p  with multiple constructors for the  single class.,[object Object],              #include<iostream.h>,[object Object],            #include<conio.h> ,[object Object],           class num,[object Object],         {,[object Object],             private :,[object Object]
Int  a;,[object Object],  float  b;,[object Object],    char c;,[object Object],   public :,[object Object],    num(int  m , float  j, char k);,[object Object],   num(int m , float  j);,[object Object],   num( );,[object Object],     void show( ),[object Object], {,[object Object],    cout<<“  A  =”<<a<<“  B=“<<b<<“  C  =”<<c;,[object Object],       },[object Object],  };,[object Object],num :: num(int  m, float  j, char  k),[object Object],{,[object Object],    cout<<“  Constructor  with Three Argument   : ”;,[object Object],       a=m;  ,[object Object],        b=j; ,[object Object],         c=k;,[object Object],     },[object Object],num :: num( int  m , float  j),[object Object],{,[object Object],     cout<<“ Constructor with two  argument : ”;,[object Object],     a=m;  b=j;,[object Object],     c=‘ ‘;   },[object Object]
num :: num( ),[object Object],  {,[object Object],      cout<<“   Constructor  with  Argument  : ”;,[object Object],      a=b=c=NULL;,[object Object],      },[object Object],   void main( ),[object Object],   {,[object Object],    clrscr();,[object Object],      class   num x(4 , 5.5 ,’A’);,[object Object],       x.show( );,[object Object],     class  num y(6 , 9.7);,[object Object],        y.show( );,[object Object],     class  num  z;,[object Object],           z.show();,[object Object],         return 0;,[object Object],          },[object Object]
Copy constructor,[object Object],The constructor  can  accept arguments of any data type including  user-defined  data types and an object of its own class.,[object Object],   copy constructor :,[object Object],Statement (a),[object Object],Statement (b),[object Object],Class   num,[object Object],{,[object Object],        private:,[object Object],        -------------,[object Object],        ------------,[object Object],           public :,[object Object],               num(num);,[object Object],   },[object Object],Class   num,[object Object],{,[object Object],        private:,[object Object],        -------------,[object Object],        ------------,[object Object],           public :,[object Object],               num(num&);,[object Object],   },[object Object],IN stmt(a)  an argument of the constructor is same as that of its class.Hence this declaration is wrong.It is possible to pass reference of object to the constructor. Such declaration is known as copy constructor. The stmt(b) is valid and can be used to copy constructor.,[object Object]
  When we pas an object by value into a function,a temporary copy  of that object is created.All copy  constructors require one argument,with reference to an object of that class.Using  copy constructors,it  is possible for the programmers to declare and initialize one  object using reference of another object.Thus, whenever a constructor  is called a copy of an object is created.,[object Object],  Example:  ,[object Object],                  #include<iostream.h>,[object Object],                  class num,[object Object],                      {,[object Object],                          int  n;,[object Object],                            public :,[object Object],                             num( )      //  constructor   without argument,[object Object],                            {   },[object Object],                          num (int  k)   //  constructor with argument,[object Object],                         {,[object Object],                              n=k;,[object Object],                             },[object Object],                          num(num  &j)   // copy constructor  ,[object Object],                           {,[object Object],                                n=j.n;,[object Object],                              },[object Object]
   void  show( ),[object Object],  {,[object Object],     cout<<n;,[object Object],      },[object Object],         };,[object Object],      void main( ),[object Object],     {,[object Object],         num j(1);,[object Object],         num k(j);,[object Object],          num l=j;,[object Object],           num  m;,[object Object],              m=j;,[object Object],      cout<“  Object J value  of  n: ”;,[object Object],        j.show();,[object Object],        cout<<“ Object k value  of n : ”;,[object Object],         k.show();,[object Object],       cout<<“ Object L value of  n : ”;,[object Object],              l.show();,[object Object],        cout<<“  Object M value of  n : ”;,[object Object],                   m.show();,[object Object],                  },[object Object]
Example :  Write a program to invoke Constructor  & Destructor .,[object Object],                 #include<iostream.h>,[object Object],                    class  byte,[object Object],                 {,[object Object],                    int  bit;,[object Object],                  int  bytes;,[object Object],                   public :,[object Object],                    byte( ),[object Object],                {,[object Object],                   cout<<“  Constructor invoked : ”;,[object Object],                    bit=64;,[object Object],                    bytes=bit/8;  },[object Object],                      ~byte(),[object Object],                        {,[object Object],                          cout<<“ Destructor Invoked  : ”;,[object Object],                            cout<<“  Bit  = ”<<bit;,[object Object],                             cout<<“ Byte = ”<<bytes;,[object Object],                             },[object Object],                     };,[object Object],                            int  main( ),[object Object],                            {,[object Object],                                byte   x;,[object Object],                               byte( );   //  calling constructor  ,[object Object],                           x.byte::byte();      x.byte ::~byte( );  },[object Object]
Friend Function,[object Object],It is not a member function .But it has complete access on all  types of properties of a class.,[object Object],Characteristics of friend function :,[object Object],Friend function is signatured with in the class & prefixed with friend keyword. It mean’s the signature defines these functions friend of current class.,[object Object],It is not called associated with <object>.,[object Object],It takes class  objects as parameter.,[object Object],It is friend of one or many class as.,[object Object],Syntax :,[object Object],   friend  <return type>  <function_name> (<parameters>);,[object Object],  when we are defined the function is out of the class.,[object Object],   <return type> <FunctionName> (<parameter>),[object Object],    {,[object Object],       -----------,[object Object],       },[object Object]
Example:,[object Object],          #include<iostream.h>,[object Object],        class test,[object Object],   {,[object Object],        int a,b;,[object Object],            public :,[object Object],             test(),[object Object],         {,[object Object],             a=b=0;,[object Object],               },[object Object],          test(int x,int y),[object Object],        {,[object Object],          a=x;  b=y;,[object Object],            },[object Object],       friend  void sum(test);,[object Object],        };,[object Object],     void sum(test  temp),[object Object],    {,[object Object],       cout<<“ Sum of  “<<temp.a+temp.b;,[object Object]
   },[object Object],  void main( ),[object Object],  {,[object Object],       test  t1(3,4);,[object Object],       test  t2(5,6);,[object Object],       sum(t1);,[object Object],    sum(t2);,[object Object],    getch();,[object Object],},[object Object]
Friend Function   ,[object Object],The idea of Encapsulation and data hiding concept is that  any non-member function has no  access permission to the private data of the class. The private members of the class are accessed only from member functions of that class. Any non-member function cannot access the private data of the class.,[object Object],              C++ allows a mechanism, in which a non-member has access permission to the private members of the class. This can be done by declaring a non-member function to the class  whose private data is to be accessed. Here friend is a keyword. ,[object Object],  Example :   #include<iostream.h>,[object Object],                   class  ac,[object Object],                     {,[object Object],                        private :,[object Object],                          char name[10];,[object Object],                           int  acno;,[object Object],                           float  bal;,[object Object],                        public :,[object Object],                        void   read( ),[object Object],                       {,[object Object],                         cout<<“   Enter the Name  : ”;,[object Object],                          cin>>name;,[object Object],                         cout<<“ Enter u r A/c No : ”;,[object Object],                           cin>>acno;,[object Object],                            cout<<“ Balance”;,[object Object],                              cin>>bal;   },[object Object]
Friend  void showbal(ac);,[object Object],     };,[object Object],    void  showbal(ac   a),[object Object],       {,[object Object],      cout<<“ Balance of A/c No. ”<<a.acno<<“ is Rs. ”<<a.bal;,[object Object],          },[object Object],    int main(),[object Object],  {,[object Object],      ac k;,[object Object],    k.read();,[object Object],      showbal(k);,[object Object],     },[object Object],Ex: To declare  Friend function in two classes .,[object Object],              #include<iostream.h>,[object Object],                 class first;,[object Object],                class  second,[object Object],              {,[object Object],                 int  s;,[object Object],                      public :,[object Object],                         void getvalue(),[object Object],                       {,[object Object],                         cout<<“ Enter a number : “    ;,[object Object],                         cin>>s;,[object Object],                    },[object Object]
Friend  void sum(second, first);,[object Object],    };,[object Object],   class  first,[object Object],    {,[object Object],       int  f;,[object Object],           public :,[object Object],            void getvalue(),[object Object],            {,[object Object],               cout<<“ Enter a number : ”;,[object Object],                 cin>>f;,[object Object],                },[object Object],          friend  void sum(second,first);,[object Object],             };,[object Object],  void sum( second   d, first  t),[object Object],  {,[object Object],     cout<<“ Sum of two numbers  : ”<<t.f+d.s;,[object Object],    },[object Object],    void  main( ),[object Object],    {,[object Object],          first   a;   second   b;,[object Object],     a.getvaule()  ,[object Object],b.getvaule();,[object Object],     sum(b,a);,[object Object],},[object Object]
Operator overloading,[object Object],The capability to relate the existing operator with a member function and use the resulting operator with objects of its class as its operands is called operator overloading. ,[object Object],    syntax :,[object Object],              return type   operator   operator symbol(parameters ),[object Object],             {,[object Object],                    statements ;,[object Object],                    --------------,[object Object],                 } ,[object Object],Example : W.A.P to perform  addition of two objects and store the result in third object.,[object Object],              #include<iostream.h>,[object Object],              class   number,[object Object],               {,[object Object],                   public :,[object Object],                         int  x,y;,[object Object],                     number( )                         {     } ,[object Object],                  number(int  j, int k),[object Object],         {,[object Object]
      x=j;   y=k;,[object Object],      },[object Object],  void show( ),[object Object],  {,[object Object],   cout<<“  x=”<<x<<“  y=”<<y;,[object Object],       },[object Object],  };,[object Object],    void  main( ),[object Object],   {,[object Object],        clrscr();,[object Object],   number A(2,3),B(4,5),C;,[object Object],   A.show();,[object Object],  B.show();,[object Object],   C.x=A.x+B.x;   //  Adding of two Argument ,[object Object],   C.y=A.y+B.y;   //  using member variables directly.,[object Object],    C.show();,[object Object],    },[object Object]
The keyword ‘Operator’ ,followed by an operator symbol, defines a new(overloaded) action of the given operator.,[object Object],     Example   :,[object Object],                   number  operator   +  (number  D),[object Object],                        {,[object Object],                             number  T;,[object Object],                           T.x=x+D.x;,[object Object],                           T.y=y+D.y;,[object Object],                             return T;,[object Object],                          },[object Object], The overloaded operators are redefined within a C++ Class using the keyword operator followed by an operator symbol. when an operator is overloaded, the produced symbol is called the operator function name. In the above declarations provide an extra meaning to the operator. Operator functions should be either member functions or friend functions. A friend function requires one argument for  unary operators and two for binary operator.  The member function requires one argument for binary operators and no argument for unary operators.,[object Object],The prototype  of operator functions in classes can be written as follows : ,[object Object],      1)  void operator ++();,[object Object],       2) void operator  --();,[object Object],      3)  void operator –();,[object Object],    4) num operator +(num);,[object Object],    5) friend num operator * (int , num);,[object Object],Here  using friend function ,it is essential to pass the objects by value or reference .,[object Object]
Operator overloading can be carried out in the following  steps :,[object Object],Define a class which is to be used with overloading operations.,[object Object],The public declaration section of the class should contain the prototype of the function ,[object Object],                  operator( ).,[object Object],Define of the operator( ) function with proper operations for which it is declared.,[object Object],Example :    #include<iostream.h>,[object Object],                    class number ,[object Object],                   {,[object Object],                       public :,[object Object],                        int x,y;,[object Object],                      number( )   //  zero  argument constructor.,[object Object],                     {       },[object Object],                      number(int i, Int j)  // two argument constructor.,[object Object],                       {,[object Object],                          x=i;,[object Object],                            y=j;,[object Object],                          },[object Object],                   number operator +(number D),[object Object],                      {,[object Object],                       number T;,[object Object],                       T.x=x+D.x;,[object Object],                      T.y=y+D.y;,[object Object],                        return T;,[object Object],                      },[object Object]
 void   show(),[object Object], {,[object Object],   cout<<“ X =”<<x<<“ y=“<<y;,[object Object],       },[object Object],   };,[object Object],       void main( ),[object Object],       {,[object Object],          clrscr();,[object Object],     number A(1,2),B(3,4),C;,[object Object],      A.show();,[object Object],      B.show();,[object Object],      C=A+B;,[object Object],      C.show();,[object Object],       },[object Object],Overloading Unary operators  :,[object Object],Overloading devoid of explicit argument to an operator function is called as unary operator overloading. The operator ++,--,- are unary operators. It can be used as prefix or suffix with the functions.,[object Object],Example :  W.A.P to increment member variables of object. Overload unary ++ operator.,[object Object]
#include<iostream.h>,[object Object],Class num,[object Object], {,[object Object],   private :,[object Object],     int a,b,c,d;,[object Object],       public:,[object Object],     num(int j, int k, int m,int n),[object Object],   {,[object Object],       a=j;  b=k;  c=m;  d=n;,[object Object],          },[object Object],   void show(),[object Object],   {,[object Object],	cout<<“ A =”<<a<<“ B=“<<b<<“ C=“<<c<<“ D=”<<d;,[object Object],    },[object Object],void operator ++(),[object Object],   {,[object Object],    ++a;   ++b;  ++c;  ++d;,[object Object],     },[object Object],};,[object Object],     void  main( ),[object Object],   {,[object Object],   num X(3,4,5,6);,[object Object]
Cout<<“ Before Increment of  X :”<<endl;,[object Object],  X.show();,[object Object],     ++X;,[object Object],   cout<<“ After increment of X :”;,[object Object],     X.show();,[object Object],         return 0;,[object Object],         },[object Object],Binary operators :   overloading with a single parameter is called as binary operator overloading. Like unary operators, binary operator can also be overloaded. Binary operators require two operands. Binary operators are overloaded by using member function and friend function.,[object Object],   1) overloading binary operator using member functions :,[object Object],If overloaded as a member function they require one argument. The argument contains value of the object, which is to the right of the operator. If we want to perform the addition of two objects o1 and o2,the overloading function should be declared as follows.,[object Object],           operator (num o2);,[object Object],     where num is a class name and o2 is an object.,[object Object],To call function operator the statement is as follows  :,[object Object],          o3=o1+o2;,[object Object],     we know that a member function can be called by using class of that object. Hence ,the called member function is always preceded by the object. The object o1 invokes the function operator() and the object o2 is used as an argument for the function. The statement can also be written as follows .,[object Object]
o3=o1.operator +(o2);,[object Object],   Here, the data members of o1 are passed directly and data members of o2 are passed as an argument. While overloading binary operators, the left-hand operand calls the operator function and right hand operand is used as an argument.,[object Object],  Example :  #include<iostream.h>,[object Object],                    class  num,[object Object],                 {,[object Object],                     private :,[object Object],                  int  a,b,c,d;,[object Object],                   public :,[object Object],                    void input();,[object Object],                    void show();,[object Object],                 num operator +(num);,[object Object],                };,[object Object],        void num :: input(),[object Object],          {,[object Object],        cout<<“ Enter the value’s for a,b,c,d : ”;,[object Object],           cin>>a>>b>>c>>d;,[object Object],                    },[object Object],                void num :: show(),[object Object],               {,[object Object],                 cout<<“ A=“<<a<<“ B=“<<b<<“ C=“<<c<<“ D=”<<d<<endl;,[object Object],                       },[object Object],            num num :: operator +(num t),[object Object],     {,[object Object]
num tmp;,[object Object],   tmp.a=a+t.a;,[object Object],    tmp.b=b+t.b;,[object Object],   tmp.c=c+t.c;,[object Object],  tmp.d=d+t.d;,[object Object],   return (tmp);   ,[object Object],},[object Object],   main(),[object Object],  {,[object Object],      num x, y, z;,[object Object],    cout<<“ Object X : ”;,[object Object],    x.input();,[object Object], cout<<“  Object Y : ”;,[object Object],    y.input();,[object Object],     z=x+y;,[object Object],        cout<<“ X : ”;,[object Object],        x.show();,[object Object],         cout<<“ Y : ”;,[object Object],          y.show();,[object Object],              cout<<“ Z : ”;,[object Object],               z.show();,[object Object],              },[object Object]
Overloading Binary Operators using Friend Function :,[object Object],        The friend function can be used alternatively with member functions for overloading of binary operators. The friend function requires two operands to be passed as arguments.,[object Object],             o3=o1+o2;,[object Object],            o3=operator +(o1,o2);,[object Object],  Both the above statements have the same meaning. In the second statement, two objects  are passes  to the operator function.,[object Object],    The use of member function and friend function produces the same result. Friend functions are useful when we require performing an operation with operand of two different types.,[object Object],          x=y+3;,[object Object],           x=3+y;,[object Object],          where x,y are objects of same type. The first statement is valid. However, the second statement will not work. The first operand must be an object of the class. This problem can be overcome by using friend function. The friend function can be called without using object. The friend function  can be used with standard data type as left-hand operand and with an object as right-hand operand. ,[object Object]
Ex:   #include<iostream.h>,[object Object],          class  num,[object Object],        {,[object Object],           private :,[object Object],             int a,b,c,d;,[object Object],              public :,[object Object],               void input();,[object Object],               void show();,[object Object],          friend num operator *(int ,num);,[object Object],                };,[object Object],   void num  :: input (),[object Object],     {,[object Object],        cout<<“  Enter values for a,b,c,d : ”;,[object Object],         cin>>a>>>b>>c>>d;,[object Object],        },[object Object],       void num :: show(),[object Object],      {,[object Object],         cout<<“  A =”<<a<<“ B=”<<b<<“ C=“<<c<<“ D=“<<d<<endl;,[object Object],             }  num operator * (int a,num t),[object Object],         {,[object Object],             num tmp;,[object Object],         tmp.a=a*t.a;,[object Object],          tmp.b=b*t.b;,[object Object]
    tmp.c=c*t.c;,[object Object],  tmp.d=d*t.d;,[object Object],    return (tmp);,[object Object],      },[object Object],Void  main( ),[object Object],  {,[object Object],    num x, z;,[object Object],    cout<<“ Object  X  :”;,[object Object],     x.input();,[object Object],       z=3*x;,[object Object],      cout<<“  X : ”;,[object Object],      x.show();,[object Object],       cout<<“ Z : ”;,[object Object],        z.show();,[object Object],               },[object Object]
Type conversion,[object Object],When constants and variables  of various data types are clubbed in a single expression, automatic type conversion takes place. This is so for basic data types. The compiler  has no idea about the user-defined data types and about  their  conversion  to other data types. The programmer should  write the routines that convert basic types to user-defined  data types  or vice versa.,[object Object],   There are three possibilities of data conversion as .,[object Object],   1)  Conversion from basic data type to user -defined  data type (class type).,[object Object],   2)  Conversion  from  class type to basic data type.,[object Object],   3)  Conversion from one class type to another class type.,[object Object],Conversion  from basic data type to class type  :,[object Object],                   The conversion from basic to class data type is easily carried out. It is automatically done  by  the compiler  with the help of in-built routines  or by applying  type casting. In  this type the left-hand operand of “ = “ sign is always  class type and right –hand operand is always basic types.   ,[object Object]
Example    :     This program to define constructor with no argument and with float argument.  Explain  how the complier invokes constructor  depending on data types.,[object Object],                          #include<iostream.h>,[object Object],                         class data ,[object Object],                         {,[object Object],                            int   x;,[object Object],                            float   f;,[object Object],                             public :,[object Object],                           data( ),[object Object],                         {,[object Object],                            x=0;,[object Object],                              f=0;,[object Object],                            },[object Object],                        data( float  m),[object Object],                        {,[object Object],                           x=2;,[object Object],                             f=m;,[object Object],                            },[object Object],                       void  show( ) ,[object Object],                       {,[object Object],                          cout<<“  x= ”<<x<<“ f = ”<<f;,[object Object],                           cout<<“ x= ”<<x<<“ f = “<<f; ,[object Object],                            },[object Object],                      };                       ,[object Object]
Int  main( ),[object Object],  {,[object Object],      data d;,[object Object],        d=1;,[object Object],         d.show();,[object Object],        d=6.9;,[object Object],          d.show();,[object Object],          },[object Object],2) Conversion from class to basic data type    :,[object Object],                              We already see that previous  type i.e.., how compiler  makes conversion from basic to class type. The compiler does not have any knowledge about the user-defined data type built using classes. In this type of conversion, the programmer explicitly needs to tell the compiler  how to perform conversion from class to basic data type. These instructions are written in a member function. Such type of  conversion is also known as overloading  of type cast operators. The compiler first searches for the operator keyword followed by data type and if it  is not defined, it applies the conversion functions. In this type , the left-hand operand is always of basic data type and right-hand  operand is always of class type.  ,[object Object]
Example : ,[object Object],                          #include<iostream.h>,[object Object],                        class  data ,[object Object],                       {,[object Object],                           int   x;,[object Object],                          float  y;,[object Object],                             public :,[object Object],                          data( ),[object Object],                       {,[object Object],                          x=0;,[object Object],                            y=0;,[object Object],                          },[object Object],                     operator int( ),[object Object],                        {,[object Object],                            return  (x);,[object Object],                           },[object Object],                        operator float( ),[object Object],                          {,[object Object],                             return  y;,[object Object],                              },[object Object],                        data(float  m),[object Object],                         {,[object Object],                             x=2;,[object Object],                            y=m;,[object Object],                            },[object Object]
   void  show( ),[object Object],        {,[object Object],             cout<<“  x =”<<x<<“ y =“<<y;,[object Object],               cout<<“  x =<<x<<“ y=”<<y;,[object Object],             },[object Object],  };,[object Object],     void main() ,[object Object],    {,[object Object],       int  i;,[object Object],    float  j;,[object Object],       data  d;,[object Object],        d= 9.9;,[object Object],           i=d;   //   operator  int () is executed .,[object Object],            j=d;  //   operator float () is executed.,[object Object],               cout<<“ value of  i : ”<<i; ,[object Object],                 cout<<“ value of  j : ”<<j;,[object Object],     },[object Object]
3) Conversion from one class type to another class type  :,[object Object],When an object of one class is assigned to object of another class, it is necessary to give clear-cut-instructions to the compiler. This method  must be instructed to the compiler .  These are two ways to convert object data type from one class to another. one is to define a conversion operator function  in source class or  a one-argument constructor in a destination class.,[object Object],            For example :   x=a ;,[object Object],                         here, x is an object of class XYZ and  a is object of class ABC . The class  ABC data type is converted to class XYZ. The conversion happens  from lass ABC to XYZ. The ABC is a source class and  XYZ  is a destination class. ,[object Object],                              we know the operator function OPERATOR DATA-TYPE( ) . Here the type may be built-in data type  or user defined data type. The data types indicates target type of object. Here the conversion takes place from class ABC(source class) to class  XYZ (destination Class).,[object Object],     #include<iostream.h>,[object Object],    #include<stdlib.h>,[object Object],    #include<string.h>,[object Object],      class   date,[object Object],    {,[object Object],       char  d[10];,[object Object],       public :,[object Object],           date( ),[object Object],          {,[object Object],              d[0]=NULL;,[object Object],           } ,[object Object]
    date (char  *e),[object Object],{,[object Object],   strcpy(d , e);,[object Object],     } ,[object Object],    void  show( ),[object Object],    {,[object Object],         cout<<d;,[object Object],        },[object Object],   };,[object Object],     class  dmy,[object Object],    {,[object Object],          int  mt, dy , yr;,[object Object],           public :,[object Object],        dmy( ),[object Object],      {,[object Object],          mt=dy=yr=0;,[object Object],             },[object Object],         dmy(int  m, int  d, int  y),[object Object],        {,[object Object],             mt=m;,[object Object],              dy= d;,[object Object],                yr=y;,[object Object],               },[object Object],         operator  date( ),[object Object],      {,[object Object],      char  tmp[3], dt[9];,[object Object]
itoa(dy,dt,10);,[object Object],   strcat(dt, “-”);,[object Object],   itoa(mt,tmp,10);,[object Object],   strcat(dt,tmp);,[object Object],       strcat(dt,”-”);,[object Object],     itoa(yr,tmp,10);,[object Object],    strcat(dt,tmp);,[object Object],   return(date(dt));,[object Object],      },[object Object],      void show(),[object Object],       {,[object Object],           cout<<dy<<“ “<<mt<<“ ”<<yr;,[object Object],           },[object Object],      };,[object Object],     void main( ),[object Object],    {,[object Object],         date  d1();,[object Object],          dmy  d2(1,7,99);,[object Object],               d1=d2;,[object Object],             cout<<endl<<“ D1 =”;,[object Object],               d1.show();,[object Object],            cout<<endl<<“D2 =”;,[object Object],         d2.show();,[object Object],               },[object Object]
  Example  :  Write a program to convert class type to another class data type.,[object Object],                #include<iostream.h>,[object Object],                        class  minutes,[object Object],                        {,[object Object],                           int   m;,[object Object],                         public :,[object Object],                            minutes( ),[object Object],                           {,[object Object],                                m=240;,[object Object],                              },[object Object],                           get(),[object Object],                              {        ,[object Object],                                  return  m;   },[object Object],                             void  show(),[object Object],                            {,[object Object],                               cout<<“ Minutes = ”<<m;,[object Object],                                     },[object Object],                              };,[object Object],                        class hours,[object Object],                            {,[object Object],                                int   h;,[object Object],                              public :,[object Object],                                 void  operator =(minutes  x);,[object Object],                            void  show(),[object Object],                           {,[object Object]
Cout<<“  Hours = ”<<h;,[object Object],        },[object Object],   };,[object Object],       void hours : : operator =(minutes  x),[object Object],             {,[object Object],                  h=x.get()/60;,[object Object],               } ,[object Object],        int   main( ),[object Object],           {,[object Object],              minutes   m;,[object Object],              hours     h;,[object Object],               h=m;,[object Object],               m.show( );,[object Object],               h.show();,[object Object],          return 0;,[object Object],        },[object Object]
Inheritance,[object Object],                             Inheritance is one of the most useful and essential characteristics of  OOP. The existing classes are main component’s of inheritance. The new classes are created from existing one. The properties of existing classes are simply extended to the new classes. The new classes  created using such methods are known as derived classes and the existing classes are known as base classes. The relationship between the base and derived class is known as “ Kind of relationship“. ,[object Object],                         The programmer can define new member variables and functions in the derived class. The base class remains unchanged. The object of derived class can access members of base as well as derived class. On the other hand the object of base class can’t access members of derived classes. The base classes do not know about their subclasses.,[object Object],                    The term reusability means reuse of properties of base class in the derived classes. Reusability permits to reuse members of the previous class. In the base class is reused.  Reusability is achieved using inheritance. Inheritance and reusability are not different  from each other.,[object Object],                    The base class is called as super class, parent or ancestor and derived class as sub class, child or descendent.   ,[object Object]
Base Class,[object Object],MEMBER  B,[object Object],MEMBER  A,[object Object],Inheritances,[object Object],Derived Class,[object Object],MEMBER  C,[object Object],MEMBER D,[object Object],Defination  :,[object Object],The procedure of creating a new class from one or more existing classes is termed as inheritance.,[object Object]
Syntax :,[object Object],              class name of the derived class :  access specifiers - name of the base class,[object Object],                  {,[object Object],                     -----------------------------,[object Object],                     -----------------------------   // member variables of new class(derived class) ,[object Object],                     -----------------------------,[object Object],                      },[object Object],   The derived class name and base class names are separated by colon (:) .The access specifiers  may be private or public . The keyword private ort public is specified followed by colon. Generally, the access specifier is to be specified. In the absence of access specifier  the default is private the access specifiers decide whether the characteristics of the base classes are derived  privately or publicly. The derived class also has it’s own set of member variables and functions.,[object Object],    Syntax : ,[object Object],                  class B : public A,[object Object],                    {,[object Object],                     -----   /// members of class B,[object Object],                     -----,[object Object],                        },[object Object]
Public :,[object Object],          A class can be derived publicly or privately. when a class is derived publicly all the public members of base class can be accessed directly in the derived class whereas in private derivation an object of derived class has no permission to access even public  members of the base class directly. In such a case the public members of the base  can be accessed using public member functions of the derived class. ,[object Object],   Example :  #include<iostream.h> ,[object Object],                     class   A       // Base class,[object Object],                     {,[object Object],                          public :   ,[object Object],                            int x;,[object Object],                          };,[object Object],                      class  B : public A          // Derived class,[object Object],                       {,[object Object],                       public : ,[object Object],                             int y;,[object Object],                           };,[object Object],                      void main( ),[object Object],                       {,[object Object],                           B   b;,[object Object],                          b.x=20;,[object Object],                           b.y=30;,[object Object],                           cout<<“ member of  A :”<<b.x;,[object Object],                         cout<<“ Member of B :”<<b.y;,[object Object],                },[object Object]
Private inheritance :,[object Object],                   The object of privately derived class cannot access the public members of the base class directly. hence member functions are used to access the members.,[object Object],Example :      #include<iostream.h>,[object Object],                       class  A ,[object Object],                  {,[object Object],                        public :,[object Object],                          int x;,[object Object],                  };,[object Object],                   class B : private A,[object Object],                     {,[object Object],                          public :,[object Object],                             int y;,[object Object],                           B(),[object Object],                       {,[object Object],                          x=20;,[object Object],                         y=40;,[object Object],                        },[object Object],               void show(),[object Object],                {,[object Object],                   cout<<“ x=”<<x;,[object Object],                  cout<<“ y=”<<y;,[object Object],                },[object Object],      };,[object Object]
Void main( ),[object Object], {,[object Object],    B    b;,[object Object],   b.show();,[object Object],      },[object Object],Protected data with private inheritance :,[object Object],                     The member functions of derived class cannot access the private variables of base class. The private members of base class can be accessed using public member functions of the same class. This approach makes a program lengthy. To overcome the problem associated with private data the creator of C++ introduced another access specifier  called protected. The protected is same as private, but it allows the derived class to access the private members directly. ,[object Object],Example :,[object Object],                      #include<iostream.h>,[object Object],                         class  A,[object Object],                       {,[object Object],                          protected :,[object Object],                        int x;,[object Object],                          },[object Object],                 class B : private A,[object Object],                     {,[object Object],                         int  y;,[object Object],                       public ;,[object Object],                       B( ),[object Object],                     {,[object Object]
    x=30;,[object Object],       y=40;,[object Object],         },[object Object], void show(),[object Object],  {,[object Object],       cout<“ X =”<<x;,[object Object],         cout<<“  Y =<<y”;,[object Object],             },[object Object],         };,[object Object],             void main(),[object Object],           {,[object Object],               B  b;,[object Object],             b.show();,[object Object],                },[object Object],Access specifier with their scopes   :,[object Object],Derived class access mode,[object Object],Base class access mode,[object Object],Private derivation,[object Object],Public derivation,[object Object],Protected derivation,[object Object],Public,[object Object],Protected,[object Object],Private ,[object Object],Public,[object Object],Private ,[object Object],Not inherited,[object Object],Nor inherited,[object Object],Not inherited,[object Object],Protected,[object Object],Private ,[object Object],Protected,[object Object],Protected,[object Object]
Accessible to member functions of the same class,derived class, and using objects. When a class is derived by private derivation, public members of the base class are private in the derived class.,[object Object],Accessible to member functions inside its own class but not in derived class. The derived class cannot access the private members of the base class directly. The private members of the base class can be accessed  only by using public member  functions  of the same class.,[object Object],Accessible to member functions of base and derived class. When a class is derived privately, the protected members of the class become private and when derived  publicly, the protected members remain protected in the derived class.,[object Object], Types of inheritances ,[object Object],A simple inheritance that uses one base class and one derived class. The process of inheritance can be a simple one or may be complex.,[object Object],This depends on following points :,[object Object],Number of base classes : The program can use one or more base classes to derive a single class.,[object Object],Nested derivation : The  derived class can be used as base class and new class can be derived from it. This can be possible to any extent.,[object Object]
1. Single level inheritance.    ,[object Object],2. Multiple inheritance.,[object Object],3. Hierarchical inheritance.,[object Object],4. Multilevel Inheritance.,[object Object],5. Hybrid inheritance.,[object Object],6. Multi-path inheritance.,[object Object],Single level Inheritance :,[object Object],                 when only base class is used for derivation of a class and the derived class is not used as base class, such type of inheritance between one base and derived class is known as single inheritance.     ,[object Object],X,[object Object],Base class,[object Object],Here X is a base class. Y is a derived class. This type  involves one base  and derived class. Further no class is derived from Y. ,[object Object],Y,[object Object],Derived class,[object Object],Multiple Inheritance :,[object Object],                     when two or more base classes are used for derivation of a class, it is called multiple inheritance. ,[object Object],In this multiple inheritance X&Y are base classes. Z is a derived class. Class Z inherits properties of both X&Y.  Further Z is not used as a base class. ,[object Object]
Base class,[object Object],X,[object Object],Y,[object Object],Z,[object Object],Derived class,[object Object],Multilevel Inheritance :,[object Object],                  when a class base class is derived from another derived class i.e..,  derived class acts as a base class, such type of inheritance is known as Multilevel inheritance.,[object Object],W,[object Object],X is a base class. Y is derived  from  X. Further, Z is derived from Y. Here, Y is not only  a derived  class but also a base class. Further, Z can be used as a base class.,[object Object],X,[object Object],Y,[object Object],Z,[object Object],Hierarchical Inheritance :,[object Object],              when a single base class is used fro derivation of two or more classes. It it known as hierarchical inheritance.,[object Object],Here W is only one base class. X,Y & Z are derived  classes . Further X, Y, Z are not used for deriving a class.,[object Object]
W,[object Object],Z,[object Object],Y,[object Object],X,[object Object],Hybrid Inheritance :,[object Object],                The combination of one or more type of inheritance is known as hybrid inheritance. ,[object Object],In this type, two types of inheritance is used i.e.., single and multiple inheritance . Class Y is derived from class X. It is a single type of inheritance .Further the derived class Y acts as a base class. The class W is derived from base classes Y & Z. This type of inheritance  that uses more  than one base class is  known  as multiple inheritance. Thus combination of one or more type of inheritance is called hybrid inheritance.  ,[object Object],X,[object Object],Y,[object Object],Z,[object Object],W,[object Object],Multipath inheritance :,[object Object],when a class is derived from two or more classes that are derived from same base class such type of inheritance is known as multipath inheritance.,[object Object]
W,[object Object],X,[object Object],Y,[object Object],Z,[object Object],W  is a base class. The classes X &Y are derived from W base class. Both X & Y inherit properties of class W. Class Z is derived from X & Y. X&Y have same copies of members inherited from W. Here ambiguity is generated. Hence virtualkeyword is used to avoid ambiguity.,[object Object],Single level inheritance  :,[object Object],When only one class is derived from a single base class such derivation of a class is known as single inheritance.,[object Object],Example :        #include<iostream.h>,[object Object],                         class   ABC,[object Object],                       {,[object Object],                          protected :,[object Object],                           char name[10];,[object Object],                             int  age;,[object Object],    };,[object Object],class  abc : public ABC   //  public derivation ,[object Object],                {,[object Object]
  float  height;,[object Object],    float  weight;,[object Object],        public :,[object Object],          void getdata( ),[object Object],      {,[object Object],          cout<“ Enter the Name and age  :  ”;,[object Object],          cin>>name>>age;,[object Object],            cout<<“ Enter height and weight  :  ”;,[object Object],              cin>>height>>weight;,[object Object],            },[object Object],     void show( ),[object Object], {,[object Object],     cout<<“ Name : “<<name <<“ Age : “<<age;,[object Object],    cout<<“ Height : “<<height <<“ Feets ”<<“ weight :” <<weight<<“kg . “;,[object Object],               },[object Object],         };,[object Object],    void main( ),[object Object],   {,[object Object],      clrscr( );,[object Object],    abc   x;,[object Object],    x.getdata( );,[object Object],   x.show( );,[object Object],    getch( );,[object Object],     },[object Object]
Multilevel inheritance,[object Object],The procedure of deriving  a class from derived class is named as multilevel inheritance.,[object Object],  Example :       #include<iostream.h>,[object Object],                            class  A1,[object Object],                         {,[object Object],                            protected:,[object Object],                              char name[10];,[object Object],                                int  age;,[object Object],                             };,[object Object],                         class A2 :  public  A1,[object Object],                            {,[object Object],                                protected:,[object Object],                                  float  height;,[object Object],                                   float  weight;,[object Object],                               };,[object Object],                           class A3 : public A2,[object Object],                              {,[object Object],                                 protected:,[object Object],                                    char sex;,[object Object],                                      public:,[object Object],                                         void get(),[object Object],                                        {,[object Object],                                        cout<<“ Name : ”;,[object Object],                                         cin>>name;,[object Object],                                      cout<<“  Age : ”;,[object Object],                                       cin>>age;,[object Object]
Cout<<“ Sex : ” ;,[object Object], cin>>sex;,[object Object],   cout<<“ Height  : ” ;,[object Object],    cin>>height;,[object Object],   cout<<“  Weight : ” ;,[object Object],    cin>>weight;,[object Object],},[object Object],    void show( ),[object Object],  {,[object Object],      cout<<“ Name :”<<name;,[object Object], cout<<“ Age  :”<<age;,[object Object], cout<<“ Sex :”<<sex <<“ years ”;,[object Object],cout<<“ Height :”<<height<<“ Feets”;,[object Object],cout<<“ Weight :”<<weight<<“ kg”;,[object Object],    },[object Object],};,[object Object],       void main( ),[object Object],    {,[object Object],       clrscr();,[object Object],         A3    x;,[object Object],     x.get();,[object Object],x.show();,[object Object],   getch();,[object Object],   },[object Object]
Multiple Inheritance   : ,[object Object],When a class is derived from more than one class then this type of inheritance is called as multiple Inheritance.  ,[object Object],Example :     #include<iostream.h>,[object Object],                    class  A ,[object Object],                    {  ,[object Object],                        protected :  ,[object Object],                           int a;,[object Object],                       };,[object Object],                  class   B,[object Object],                     {,[object Object],                       protected:,[object Object],                          int b;,[object Object],                       };,[object Object],                  class  C,[object Object],                       {,[object Object],                           protected :,[object Object],                              int c;,[object Object],                          };,[object Object],             class    D,[object Object],                  {,[object Object],                  protected :,[object Object],                     int d;,[object Object],          };,[object Object],           class  E : public A,B,C,D           //  Multiple Inheritance       ,[object Object]
{,[object Object],    int  e;,[object Object],      public : ,[object Object],        void getdata(),[object Object],      {,[object Object],           cout<<“ Enter the values of  a, b, c, d &e : ”;,[object Object],          cin>>a>>b>>>c>>d>>e;,[object Object],        },[object Object],      void show(),[object Object],        {,[object Object],     cout<<“ A : ”<<a;,[object Object],      cout<<“ B : ”<<b;,[object Object],       cout<“  C : ”<<c;,[object Object],        cout<<“ D : ”<<d;,[object Object],         cout<<“ E : ”<<e;,[object Object],       },[object Object],    };,[object Object], void main(),[object Object],   {,[object Object],    clrscr();,[object Object],    E    x;,[object Object],    x.getdata();,[object Object],    x.show();,[object Object],     getch();,[object Object],},[object Object]
Hierarchical Inheritance  :  ,[object Object],In this inheritance one class could be inherited from one or more  classes. new members are added to the derived class. Inheritance also supports hierarchical arrangement of programs. Several programs require hierarchical arrangement of classes, in which derived classes share the properties of base class. Hierarchical unit shows top down style through splitting a compound class into several simple sub classes. ,[object Object],Ex :    #include<iostream.h>,[object Object],          class  red,[object Object],          {,[object Object],            public :,[object Object],             red( ),[object Object],             {   ,[object Object],                cout<<“ Red ”;,[object Object],                     },[object Object],                };,[object Object],           class  yellow ,[object Object],             {,[object Object],                public :,[object Object],                   yellow(),[object Object],                 {,[object Object],                    cout<<“ Yellow ”;,[object Object],                        },[object Object],                    };,[object Object],               class blue,[object Object],                  {,[object Object]
   public :,[object Object],     blue(),[object Object],     {,[object Object],        cout<<“  Blue : ”;,[object Object],           },[object Object],      };,[object Object],Class orange : public red, public yellow,[object Object],   {,[object Object],      public:,[object Object],     orange(),[object Object],     {,[object Object],         cout<<“ Orange :”;,[object Object],          },[object Object],   };,[object Object],    class green : public blue, public yellow,[object Object], {,[object Object],     public:,[object Object],           green(),[object Object],      {,[object Object],          cout<<“ Green : ”;,[object Object],               },[object Object],           };,[object Object],    class  violet : public red, public yellow,[object Object],     {,[object Object],         public :,[object Object],          violet(),[object Object],        {,[object Object],              cout<<“  Violet : ”;,[object Object],         },[object Object],};,[object Object]
Class reddishbrown : public orange, public violet,[object Object],   {,[object Object],       public:,[object Object],      brown( ),[object Object],        {,[object Object],     cout<<“ ReddishBrown  : ”;,[object Object],         },[object Object],   };,[object Object],Class yellowbar : public green, public orange,[object Object],   {,[object Object],       public:,[object Object],      brown( ),[object Object],        {,[object Object],     cout<<“ Yellow ishbrown ”;,[object Object],         },[object Object],   };,[object Object],Class blueishbrown : public violet, public green,[object Object],   {,[object Object],       public:,[object Object],      brown( ),[object Object],        {,[object Object],     cout<<“ Blue-ishbrown : ”;,[object Object],         },[object Object],   };,[object Object], void main(),[object Object],  {,[object Object],    reddidshbrown   r;,[object Object],   endl(cout);,[object Object]
Bluishbrown   b;,[object Object],     endl(cout);,[object Object],      yellowishbrown    y;,[object Object],       endl(cout);,[object Object],    getch( );,[object Object],},[object Object],Hybrid Inheritance:  The combination of one or more types  of inheritance  is known as hybrid inheritance. ,[object Object],Example :     #include<iostream.h>,[object Object],                     class  player,[object Object],                     {,[object Object],                          protected:,[object Object],                           char name[10];,[object Object],                            char gender;,[object Object],                             int age;,[object Object],                         };,[object Object],                     class  physique : public player,[object Object],                        {,[object Object],                        protected:,[object Object],                          float height;,[object Object],                            float  weight;,[object Object],                         };,[object Object]
Class  location,[object Object],  {,[object Object],     protected :,[object Object], char city[10];,[object Object],Char pin[7];,[object Object],    };,[object Object],Class game : public physique ,location,[object Object],  {,[object Object],   protected :,[object Object],    char game[15];,[object Object],     public :,[object Object],       void getdata(),[object Object],    {,[object Object],   cout<<“ Enter the Data  : ”; ,[object Object],   cout<<“ Name  : ”;  cin>>name;,[object Object],   cout<<“ Gender : ”; cin>>gender;,[object Object],   cout<<“ Age : ”; cin>>age;,[object Object],  cout<<“ Height : ”; cin>>height;,[object Object], cout<<“ Weight : ”; cin>>weight;,[object Object],    cout<<“ City : ”; cin>>city;,[object Object],    cout<<“ Pin code :”; cin>>pincode;,[object Object],   cout<<“ Game : ”; cin>>game;,[object Object],       },[object Object],Void show( ),[object Object],  {,[object Object]
Cout<<“ The Data information was: ”;,[object Object],cout<<“ Enter the Data  : ”; ,[object Object],   cout<<“ Name  : ”;  cout<<name;,[object Object],   cout<<“ Gender : ”; cout<<gender;,[object Object],   cout<<“ Age : ”; cout<<age;,[object Object],  cout<<“ Height : ”; cout<<height;,[object Object], cout<<“ Weight : ”; cout<<weight;,[object Object],    cout<<“ City : ”; cout<<city;,[object Object],    cout<<“ Pin code :”; cout<<pincode;,[object Object],   cout<<“ Game : ”; cout<<game;,[object Object],       },[object Object],  };,[object Object],      void main(),[object Object],   {,[object Object],  clrscr();,[object Object],     game   g;,[object Object],    g.getdata();,[object Object],   g.show();,[object Object],    },[object Object]
Multipath inheritance   : ,[object Object],When a class is derived from two or more classes, which are derived from the same base class such type of inheritance is known as Multipath Inheritance. Multipath inheritance consists of many types of inheritance such as multiple, multilevel  and hierarchical.,[object Object],   consider the following example :,[object Object],       class   A1,[object Object],     {,[object Object],        protected :,[object Object],            int   a1;,[object Object],       };,[object Object],    class  A2 : public  A1,[object Object],    {,[object Object],         protected :,[object Object],             int   a2;,[object Object],           };,[object Object],  class  A3 : public   A1,[object Object],         {,[object Object],               protected:,[object Object],                  int   a3;,[object Object],               };,[object Object],    class   A4 : public A2, A3,[object Object],        {,[object Object],              int  a4;,[object Object],               }         ,[object Object]
In that example class A2, A3 are derived from the same base class. i.e.., class A1(hierarchical inheritance).,[object Object], The classes A2 &A3 both can access variable a1 of class A1.The class A4 is derived from class A2 & A3 by multiple inheritance.,[object Object],Virtual Base class  : ,[object Object],To overcome the ambiguity occurred due to multipath inheritance. C++ provides the keyword virtual .,[object Object],The keyword virtual  declares the specified classes virtual.,[object Object],    class    A1,[object Object], {,[object Object],protected:,[object Object],int  a1;,[object Object],};,[object Object],class  A2: virtual public A1,[object Object], {,[object Object],              protected :,[object Object],                 int a2;,[object Object],          };,[object Object],class  A2: virtual public A1,[object Object], {,[object Object],              protected :,[object Object],                 int a3;,[object Object],          };,[object Object],class  A4: public A2, A3,[object Object], {,[object Object],              protected :,[object Object],                 int a4;,[object Object],          };,[object Object]
When classes are declared as virtual, the compiler takes necessary precaution to aviod duplication of member variables. Thus we make a class virtual if it is a base class that has been used by more than one derived class as their base class.,[object Object], #include<iostream.h>,[object Object],   class A1,[object Object],    {,[object Object],      protected :,[object Object],        int a;,[object Object],       };,[object Object],    class A2: public virtual A1,[object Object],     {,[object Object],       protected:,[object Object],         int b;,[object Object],       };,[object Object],     class A3:public virtual A1,[object Object],       {,[object Object],         protected:,[object Object],          int c;,[object Object],        };,[object Object]
 class A4:public A2,A3,[object Object],       {,[object Object],         int d;,[object Object],          public:,[object Object],         void getdata(),[object Object],         {,[object Object],          cout<<" Enter the value's  :";,[object Object],           cout<<" A :";,[object Object],            cin>>a;,[object Object],            cout<<" B :";,[object Object],            cin>>b;,[object Object],            cout<<" C :";,[object Object],            cin>>c;,[object Object],            cout<<" D :";,[object Object],            cin>>d;,[object Object],           },[object Object]
 void show(),[object Object],         {,[object Object],               cout<<" The values are : ";,[object Object],                cout<<" A ="<<a;,[object Object],                cout<<" B ="<<b;,[object Object],                cout<<" C ="<<c;,[object Object],                 cout<<" D ="<<d;,[object Object],            },[object Object],       }; ,[object Object],            void  main(),[object Object],            {,[object Object],              clrscr(),[object Object],                class A4 a;,[object Object],                  a.getdata();,[object Object],                   a.show();,[object Object],                 getch();,[object Object],              },[object Object]
Constructors,Destructors And Inheritance,[object Object],The constructors are used to initialize member variables of the object and the destructor is used to destroy the object. The compiler automatically invokes constructors and destructors.The derived class does not require a constructor if the base class contains zero argument constructor. In case the base class has parameterized constructor then it is essential for the derived class to have a constructor. The derived class constructor passes arguments to the base class constructor. In inheritance, normally derived class are used to declare objects.hence, it is necessary to define constructor in the derived class.when an object of a derived class is declared,the constructor of base classes are executed.,[object Object],              In inheritance,destructor are executed in reverse order of constructor execution.The destructors are executed when an object goes out of scope.,[object Object]
Example  :       #include<iostream.h>,[object Object],                       class   A,[object Object],                    {  ,[object Object],                      public:,[object Object],                     A( ),[object Object],                  {,[object Object],                     cout<<“ This Zero Argument Constructor of A : ”;,[object Object],                    },[object Object],              ~A( ),[object Object],              {,[object Object],                  cout<<“ This is Destructor of  A : ”;,[object Object],                },[object Object],       };,[object Object],            class   B,[object Object],              {,[object Object]
public:,[object Object],                     B( ),[object Object],                  {,[object Object],                     cout<<“ This Zero Argument Constructor of  B : ”;,[object Object],                    },[object Object],              ~B( ),[object Object],              {,[object Object],                  cout<<“ This is Destructor of  B : ”;,[object Object],                },[object Object],       };,[object Object],Class  C : public A,public B    //   Derivation  of  class,[object Object],                     C( ),[object Object],                  {,[object Object],                     cout<<“ This Zero Argument Constructor of derived class C  :  ”;,[object Object],                    },[object Object],};,[object Object]
~C( ),[object Object],{,[object Object],     cout<<“ Destructor of the class  C :  ”;,[object Object],    },[object Object], };,[object Object],     void main( ),[object Object],    {,[object Object],       C   obj;    object declaration,[object Object],         },[object Object]
Pointer,[object Object],A pointer is a memory variable that stores a memory address.Pointers can have any name that is legal for other variables and it is declared in the same fashion like other variables but it is always denoted by ‘*’ operator. ,[object Object],Features of Pointers : ,[object Object],Pointers save the memory space.,[object Object],Execution time with pointer is faster because data is manipulated with the address I.e., direct access to memory location.,[object Object],The memory is accessed efficiently with the pointers.The pointer assigns the memory space dynamically that leads you to reserve a specific bytes in the memory.,[object Object],Pointers are used with data structures.They are useful for representing two-dimensional and  multi-dimensional arrays.,[object Object],In C++ , a pointer declared to a base class could access the objects of derived class. Whereas  a pointer to derived class cannot access the objects of base class.The compiler will generate an error message cannot convert ‘A *’  to ‘B *’ where A is the base class  and B is the derived class.,[object Object]
Example :  #include<iostream.h>,[object Object],                  main(),[object Object],             {,[object Object],                  int  n;,[object Object],             cout<<“ Enter a Number =  ” ;,[object Object],                 cin>>n;,[object Object],             cout<<“ value of n =”<n;,[object Object],          cout<<“ Address of n=”<<(unsigned)&n;,[object Object],                    },[object Object],Write a program to declare a pointer.Display the value and address of the variable using pointer.,[object Object],#include<stdio.h>,[object Object],   void main(),[object Object],  {,[object Object],    int  *p;,[object Object],   int   x=10;,[object Object],    p=&x;,[object Object],Printf(“ x=%d   &x=%u     (using printf( ) ) ”, x , p);,[object Object]
Cout<<“   X =  ”<<x<<“ &x = “<<&x<< “  (using cout( ) ) ” ;,[object Object],Printf(“  X = %d  &x = %u   ( Using pointer  ) ”, *p , p);,[object Object],   cout<<“  *p = ”<<*p<<“  &p =”<<p<<“  (contents of ponter) “;,[object Object],     },[object Object],void pointers,[object Object],Pointers can also be declared as void type.void pointers cannot be dereferenced without explicit type  conversion. This is because being void the compiler cannot determine the size of the object that the pointer points to. Though void pointer declaration is possible, void variable declaration is not allowed.Thus the declaration void p will display an error message “ size of ‘p’ is unknown or zero” after compilation.,[object Object],                    It is not possible to declare  void variables like pointers.pointers point to an existing entity. A void pointer can point to any type of variable with proper typecasting.The size of void pointer displayed will be two. When pointer is declared as void,two bytes are allocated to it.Later using typecasting, number of bytes can be allocated or de-allocated. Void variables cannot be declared because memory is not allocated to them and there is no place to store the address.void variables cannot actually serve the job they are made for.,[object Object]
Example :   #include<iostream.h>,[object Object],                  int  p; ,[object Object],                  float   d;,[object Object],                    char  c;,[object Object],               void *pt=&p;,[object Object],         void main(void),[object Object],     {,[object Object],        *(int *)p t=12;,[object Object],        cout<<“ p=”<<p;,[object Object],         pt=&d;                              // pt  points to d,[object Object],      *(float *) pt = 5.4;,[object Object],       cout<<“ r =”<<d;,[object Object],        pt=&c;                          // pt  points to c,[object Object],        *(char *)pt = ‘R;,[object Object],        cout<<“ C =”<<c;,[object Object],    },[object Object],output :,[object Object],                 p=12,[object Object],                r= 5.4,[object Object],               c=R,[object Object]
POINTER TO CLASS,[object Object], We know that pointer is a variable that holds the address of another data variable. The variable  may be of any data type  i.e., int ,float or double .we can also define pointer to class.here starting address of the member variables can be accessed.such type of pointer is called as class pointer.,[object Object],Example :   ,[object Object],                class book,[object Object],                {,[object Object],                     char  name[10];,[object Object],                     char  author[10];,[object Object],                     int  pages;,[object Object],                    };,[object Object],       a)   class  book   *ptr;        This is *ptr is pointer to the class book. Here both                                                         ,[object Object],                       or                        statements are  valid.,[object Object],       a)    struct  book *ptr;  ,[object Object],    The syntax for using pointer with member is given below :,[object Object],       1)   ptr->name     2)  ptr->author     3)   ptr->pages,[object Object],By executing these three statements, starting address of each member can be estimated.,[object Object]
Example :   #include<iostream.h>,[object Object],                       void  main( ),[object Object],                     {,[object Object],                        class   man,[object Object],                          {,[object Object],                              public :,[object Object],                                char name[10];,[object Object],                                 int age;,[object Object],                           };,[object Object],                    man  m={“ Raja”, 23};,[object Object],               man  *ptr;,[object Object],                ptr=&(man)m;,[object Object],                  cout<<“”<<m.name<<“ “<<m.age;,[object Object],                 cout<<“”<<ptr->name<<“ “<<ptr->age;,[object Object],                       },[object Object]
Pointer to object,[object Object],Like  variables,objects also have an address. A pointer can point to specified object.,[object Object],Example :             #include<iostream.h>,[object Object],                              class   bill,[object Object],                             {,[object Object],                                  int  qty;,[object Object],                                 float  price,amount;,[object Object],                                  public :,[object Object],                             void  getdata(int  a,float  b,float  c ),[object Object],                              {,[object Object],                                    qty=a;,[object Object]
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP
SRAVANByCPP

Weitere ähnliche Inhalte

Was ist angesagt?

pointer, virtual function and polymorphism
pointer, virtual function and polymorphismpointer, virtual function and polymorphism
pointer, virtual function and polymorphismramya marichamy
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalMichael Stal
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Kamlesh Makvana
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
Pointers Refrences & dynamic memory allocation in C++
Pointers Refrences & dynamic memory allocation in C++Pointers Refrences & dynamic memory allocation in C++
Pointers Refrences & dynamic memory allocation in C++Gamindu Udayanga
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphismlalithambiga kamaraj
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpprajshreemuthiah
 
C,c++ interview q&a
C,c++ interview q&aC,c++ interview q&a
C,c++ interview q&aKumaran K
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in Carshpreetkaur07
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Abu Saleh
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityGeorgePeterBanyard
 

Was ist angesagt? (18)

pointer, virtual function and polymorphism
pointer, virtual function and polymorphismpointer, virtual function and polymorphism
pointer, virtual function and polymorphism
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Pointers Refrences & dynamic memory allocation in C++
Pointers Refrences & dynamic memory allocation in C++Pointers Refrences & dynamic memory allocation in C++
Pointers Refrences & dynamic memory allocation in C++
 
C Theory
C TheoryC Theory
C Theory
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpp
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
C,c++ interview q&a
C,c++ interview q&aC,c++ interview q&a
C,c++ interview q&a
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
 
The Style of C++ 11
The Style of C++ 11The Style of C++ 11
The Style of C++ 11
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
 

Andere mochten auch

Andere mochten auch (15)

2009 Duke India Business Forum
2009 Duke India Business Forum2009 Duke India Business Forum
2009 Duke India Business Forum
 
Programa 2012
Programa 2012Programa 2012
Programa 2012
 
emerging technologies: mobile devices + discovery layers
emerging technologies: mobile devices + discovery layersemerging technologies: mobile devices + discovery layers
emerging technologies: mobile devices + discovery layers
 
Apresentacao unisc
Apresentacao uniscApresentacao unisc
Apresentacao unisc
 
Unidad 7
Unidad 7Unidad 7
Unidad 7
 
Unit 5 swing & TREES
Unit 5 swing & TREESUnit 5 swing & TREES
Unit 5 swing & TREES
 
exception handling in java
exception handling in java exception handling in java
exception handling in java
 
sravan java Session1
sravan java Session1sravan java Session1
sravan java Session1
 
Jtreenotes
JtreenotesJtreenotes
Jtreenotes
 
Module 4
Module 4Module 4
Module 4
 
AJP
AJPAJP
AJP
 
Util
UtilUtil
Util
 
Iostreams
IostreamsIostreams
Iostreams
 
java packages
java packagesjava packages
java packages
 
Classroom Management Tips for Kids and Adolescents
Classroom Management Tips for Kids and AdolescentsClassroom Management Tips for Kids and Adolescents
Classroom Management Tips for Kids and Adolescents
 

Ähnlich wie SRAVANByCPP

Ähnlich wie SRAVANByCPP (20)

C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
 
PRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxPRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptx
 
C++
C++C++
C++
 
Unit 1
Unit  1Unit  1
Unit 1
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming
 
C questions
C questionsC questions
C questions
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 
iOS Application Development
iOS Application DevelopmentiOS Application Development
iOS Application Development
 
C++ programing lanuage
C++ programing lanuageC++ programing lanuage
C++ programing lanuage
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
 
Notes on c++
Notes on c++Notes on c++
Notes on c++
 
C++ Programming
C++ ProgrammingC++ Programming
C++ Programming
 

Kürzlich hochgeladen

M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxDr. Santhosh Kumar. N
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsEugene Lysak
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxMYDA ANGELICA SUAN
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxKatherine Villaluna
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxKatherine Villaluna
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 

Kürzlich hochgeladen (20)

M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptx
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George Wells
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptx
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptx
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 

SRAVANByCPP

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. C++ permits declaration of variables at any place in program but such declaration is not allowed in between the statements terminated by comma operator .The initialization of previously declared variables can be done.
  • 12.
  • 13.
  • 14. Reduction in program size.
  • 15. Code duplication is avoided.
  • 16. Code reusability is provided.
  • 17. Functions can be called respectively.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.