Tuesday, February 4, 2020

CPP INTERVIEW QUESTIONS

1)Difference between C and C++?

    1)C is STRUCTURAL language and C++ is PROCEDURAL + OBJECT ORIENTED.

    2)In case of C,Importance is given to the steps (or) procedure of the program while
       C++ focuses on the data rather than the process.

    3)In case of C,the data is not secured while the data secured is in C++.

    4)C is a FUNCTION-DRIVEN while C++ is OBJECT DRIVEN.FUNCTIONS are the
       building blocks of a C program  while OBJECTS are building of a C++ program.

    5)In C++ Mapping between data & function is possible through objects but in C,it is difficult.

    6)C++ follows STRICT type check while C does not.

    7)C++ supports FUNCTION OVERLOADING while C does not.

    8)We can use FUNCTIONS inside Structures in C++ but not in C.

    9)The NAMESPACE feature in C++ is absent in case of C.

   10)C++ allows the use of  REFERENCE VARIABLES while C does not.

   11)In C++ NEW and DELETE operators are used for Dynamic memory allocation.
        In C,Library functions are used to allocate DMA.

   12)INHERITANCE is the most powerful feature in C++ but not in C.

   13)C++ supports EXCEPTION HANDLING while C does not.

   14)C++ supports TEMPLATES while C does not.

--------------------------------------------------------------------------------------------------------------


2)Difference between Printf & Scanf over cout & cin?

   1)Printf and Scanf are Library functions but cout and cin are objects.

   2)Printf and Scanf does need format specifier,cout and cin doesn't require format specifier.

   3)Printf and Scanf doesn't support user defined variables directly to print and scan the
      data members but cout and cin supports userdefined variables directly to scan and
      print the data members with the help of operator overloading.

--------------------------------------------------------------------------------------------------------------------

3)Difference between Reference and Pointer?

   1)Pointer will get separate memory.
      Reference will not get separate memory.

   2)Pointer may (or) may not be Initialized
      Reference variable must be Initialized.

   3)In It's lifetime pointer can point to any variable.
      In It's lifetime Reference variable can refer to only one variable.

   4)Null Pointer possible.
      Null Reference not possible.

   5)Pointer Explicitly will get Dereferenced.
      Reference Implicitly will get Dereference.

   6)Pointer to Pointer Possible.
      Reference to Reference not possible.

   7)Array of Pointers is Possible.
      Array of references not possible.

--------------------------------------------------------------------------------------------------------------

4)Difference between Macro and Inline Function?

   1)Macro is a Single Instruction which is replaced with Multiple Instructions.
       A Function call is replaced with Definition.

   2)It is always defined at the start of the program.
       It can be defined inside (or) outside the class.

   3)It evaluates the argument each time it is used in the code.
      It evaluates the argument only once.

   4)Macro is Mandatory statement.
      It is requesting the compiler If possible replace otherwise No.

   5)Macros are expanded by the preprocessor.
      Inline Functions are parsed by the Translator.

--------------------------------------------------------------------------------------------------------------

5)Difference between Malloc and New?

    1)Malloc is a Function.
       New is a Operator.

   2)Malloc needs sizeof operator
      New doesn't require sizeof operator.

   3)Memory Intialization Not Possible,
      Memory Intialization Possible.

   4)On success malloc function returns void pointer
      On success new operator returns exact pointer type.

   5)On Failure malloc returns Zero.
      On Failure new throw an Exception.

   6)It needs typecasting.
      New operator doesn't need (or) required typecasting.

   7)Malloc function overloading not possible
      New operator overloading possible.

   8)Up on Object creation malloc function doesn't call constructor.
      Up on Object creation new operator does call constructor.


---------------------------------------------------------------------------------------------------------------


6)Difference between Delete and Free?

   1)Free is a function
      Delete is an operator.

   2)Free Function  Overloading not Possible.
      Delete Operator Overloading possible.

   3)Free Function doesn't call destructor up on object destroying.
       Delete operator does call destructor up on object destroying.

----------------------------------------------------------------------------------------------------------------

7)Difference between the Member Function and Friend Function?

   1)Member function belongs to same class.
      Friend function not belong to same class.

   2)Member function will have this pointer.
      Friend function doesn't have this pointer.

   3)Member function must call through object.
      Friend function can Invoke directly.

   4)Member function can access the data member without object.
      Friend function can access the data members of a class through object.

   5)The scope of member function is limited to same class.
      Friend function is limited to n number of classes.

-----------------------------------------------------------------------------------------------------------------

8)Difference between Constructor and Member function ?

    1)Constructor name is having  same name as class name.
       Member function can have any legal Identifier name.

    2)Constructors doesn't have any return type.
        Member function can have return type.

    3)Constructors are used to Initialize an Object.
       Member functions are used to access/modifying the data.

    4)Constructor Constructing an Object.
        Member function not Constructing an object.

    5)Constructor will call automatically whenever an  objects get created
        Member function will invoke Explicitly.

    6)In it's lifetime of an object constructor will execute only one time .
       Member function will execute n number of times to that object.

    7)Addresses of constructor cannot be referred.
       Member function Address can be referred.

    8)Member wise Intialization possible only through constructor.
       Member wise Intialization not possible by member function.

    9)Constructor cannot be virtual.
       Member function can be virtual.

   10)Constructors cannot be Inherited.
        Member functions can be Inherited.

   11)Friend Constructor not possible.
        Member function can be friend.

-------------------------------------------------------------------------------------------------------------

9)Difference between Constructor and Destructor?

    1)Constructor is having same name as class name.
       Destructor is also having same name as a class name but prefix with Tild (~)symbol.

    2)Constructor Constructing an Object.
        Destructor Destroying an Object.

    3)Constructor Can Overloaded.
       Destructor Cannot be Overloaded.

    4)Constructor can have the arguments,
        Destructor cannot have the arguments.

    5)Constructor cannot be Virtual.
        Destructor can be Virtual.

-------------------------------------------------------------------------------------------------------------------

10)Difference between Shallow Copy and Deep Copy?

    Shallow Copy

     1)Copy one object data to another object with the help of compiler provided copy constructor (or)          Assignment overloaded operator is called shallow copy.

     2)Shallow copy is called as Member wise copy.

     3)In shallow copy both objects are pointing to the same memory location.

     4)In shallow copy if one object is modified.It will be affected to another object automatically.

     5)Shallow copy will not support for an object which contains dynamically allocated pointer.

  Deep Copy

    1)Copy one object data to another object with the help of user provided copy constructor (or)                  Assignment overloaded operator is called as Deep copy.

    2)Deep copy will support for an object which contains dynamically allocated pointer.

    3)In deep copy both objects are pointing to different memory locations.

    4)In deep copy if one object is modified it will not affect to another object.

---------------------------------------------------------------------------------------------------------------


11)What is Data Abstraction(Data Hiding) and give an Real life Example?

     1)Data abstraction can be used to provide security for the data from the unauthorized
       methods.

     2)It refers to the act of representing essential features and hiding the background details.

       Ex;-1)ATM machine
              2)Facebook
              3)Man driving a car

------------------------------------------------------------------------------------------------------------

12)What is Inheritance(ReUsability,Extensibility) and its Types. Explain with Example?.

    1)Inheritance is a mechanism in which one class acquires the property of another class
       (or)Inheritance is the process of acquiring the properties of one class  into another class.
       In this process,new classes are created called "DERIVED CLASSES" and  the existing
       classes is known  as "BASE CLASS".

   2)For example, a child inherits the traits of his/her parents.With inheritance, we can reuse
      the fields and methods of the existing class. Hence,inheritance facilitates Reusability  and
       is an important concept of  OOPs.(Banking Application).

  Types

      1)Single Inheritance(Derivation of a class from only one base class)

      2)Multilevel Inheritance(Derivation of a class from another derived class)

      3)Multiple Inheritance(Derivation of a class from several base classes)

      4)Hybrid Inheritance(Derivation of a class involving more than one form of inheritance)

      5)Hierarchical Inheritance(Derivation of several classes from a single base class)

      6)Multi path Inheritance/Diamond Inheritance(Derivation of a class from derived classes
         which  are derived from the same base class)

-----------------------------------------------------------------------------------------------------------------

 13)How is Encapsulation(Data Security) implemented and an Example?

      1)Encapsulation is a mechanism that binds together code and data into single unit
        called class,and  that keeps both safe from outside Interference and Misuse.

      2)Wrapping of data and function into a single unit is called as Encapsulation.

      3)The procedure to bind the data and functions as a single unit is called as Encapsulation.

        Ex:- Capsule which is mixed of several medicines.

----------------------------------------------------------------------------------------------------------------


14)What is Polymorphism(Flexibility) and Give an Example?

     1)A Single entity can exist in more than one form.

     2)IN C++,Polymorphism is divided as two types

         i)Compile Time Polymorphism
               a)Function Overloading
               b)Operator Overloading

        ii)Run Time Polymorphism
               a)Virtual Functions.

    Ex;-You have a smart phone for communication.The communication mode you choose
            could be anything.It can be a call,a text message,a picture message,mail etc.,So,the
            goal is common that is Communication,but their approach is different.

------------------------------------------------------------------------------------------------------------------

15)What is a Class and Object in C++. Explain by taking an Example?

       1)A)Class is advanced version of structure.

          B)Class is collection of data members and Member functions.
               Data is a member of a class is called Data Member.
               Function is a member of a class is called Member function.

       2)A)Object is a variable of a class.

           B)Object is Instance of a class.

           C)Object is Physical Existence of a Class.

           D)Object is real world Entity of a Class.

           E)Any real world entity which can have some characteristics or which can perform
               some tasks   is called as Object.

        3)A C++ Class is like a blueprint for an object.

        4)Example is Class of cars

        5)In the above example of class Car, the data member will be speed limit, mileage etc
            and   member functions can be apply brakes, increase speed etc.

        6)When a class is defined, no memory is allocated but when it is instantiated (i.e. an object
            is    created ) memory is allocated.

---------------------------------------------------------------------------------------------------------------

16)What are the Situations Where Copy Constructors is used ?
   
    a)When an object of the class is returned by value.

    b)When an object of the class is passed by value as an argument.

    c)When an object is Constructed based on another object of the same class.

    d)When a Compiler generates  a temporary object.

-------------------------------------------------------------------------------------------------------------------


17)What is Constructor?
     
          A Constructor is a special member function of a class which is invoked automatically
         when an object of the same class is created,the object gets automatically Initialized by
          the  Constructor.

-----------------------------------------------------------------------------------------------------------------

18)What are the Characteristics of Constructor?
         
        a)A Constructor has the same name as the class to which it belongs.

        b)It does not have a return type,not even void.

        c)It must be declared in the public section,if the objects are getting created outside class.

        d)Every Object of the Class Containing a Constructor is Initialized.

        e)Address of Constructor cannot be referred.

        f)A Constructor Can have the Default Arguments.

       g)Constructors Can be Overloaded.

       h)Constructors Cannot be Inherited although a derived class can call the base class
          Constructor.

       i)A Constructor Cannot be Virtual.

-------------------------------------------------------------------------------------------------------------

19)In a lifetime of an object,How many times a constructor is executed to that object ?

    Only One Time,When Object is Created.

--------------------------------------------------------------------------------------------------------------

20)Is Constructor is Constructing an Object ?

   Yes,Constructor Constructing an Object.

   a)The Object will Create Successfully  when the Memory Allocation and
      Memory Initialization done properly.

   b)Memory Allocation done by OS.

   c)Memory Initialization done by Constructor.

   d)Without Constructor Execution Object Won't be created.

   e)Constructor is executing before an object Creation.

   f)If Constructor execution is fail,then object will not be created.

------------------------------------------------------------------------------------------------------------------


21)What is Default Constructor?

     1) A Constructor which does not accept any Parameter is called Default Constructor.

     2) When a Constructor is not explicitly declared in a class,a default Constructor is added
          and is invoked during object intialization by the Compiler.

------------------------------------------------------------------------------------------------------------------

22)What is Parameterized Constructor?

        A Constructor with one (or) more arguments is known as Parameterized Constructor.

--------------------------------------------------------------------------------------------------------------------

23)What is Copy Constructor ?

        1)A Copy Constructor is a Special Case of Constructors,Used to make a Copy of One
           Class object and intialize it by using another object of the same class type .

        2)A Copy Constructor that takes a single argument which is a reference to another object
           of the same type.

------------------------------------------------------------------------------------------------------------------

24)Why Constructors do not have a return type and can have Parameters?

         Basically,Constructors are called when an object is created.And there can never exist
         a Situation where we want to return a value at the time of creation of an object.But
        there are the Situations when the data member of different objects must be Initialized
        with different  values at the time of creation.So,C++ allows ,passing of Parameters to
        the Constructor.

---------------------------------------------------------------------------------------------------------------

25)What is Destructor?

      A  destructor is a special member function of a class which is invoked automatically
      to destroy the object when the scope of the object is completed.


-------------------------------------------------------------------------------------------------------------------

26)What are Characteristics of a destructor ?

       a)A destructor will not  return any value and does not accept arguments and therefore
          it  Cannot be Overloaded.

       b)A destructor cannot be declared as Static,Const (or) Volatile.

       c)A destructor should be declared in Public Section.

       d)It is necessary that a destructor use a delete expression to deallocate the memory,
           if the constructor in the program uses the new expression for allocating the memory.

       e)A destructor is called in the reverse order of its Constructor Invocation.

------------------------------------------------------------------------------------------------------------------


27)Why Copy Constructor Collecting the Arguments With Reference Type Only?

        If a Copy Constructor accepting the syntax to collect the arguments with non reference
        type then separate memory will be created for that object and the copy constructor will
        get recursive call which leads to segmentation fault during run time.To Avoid this problem,
        the Compiler itself is restricted not to take argument as non reference.

-----------------------------------------------------------------------------------------------------------------------


28)What is Constant Member Function ?
 
        Constant Member function is a function where the data members are constant.

    Syntax: return type classname :: functionname(arg)const;

----------------------------------------------------------------------------------------------------------------------

29)What is Mutable?

        Mutable is a keyword it is used to remove the Constantness from the Particular
        Data Member.

---------------------------------------------------------------------------------------------------------------------

30)What is Operator Overloading?

            The Facility of giving a Special Meaning to an Operator without Changing the existing                         meaning is reffered to as Operator Overloading.

             An Operator can be Overloaded by Creating a Special Function called Operator function,
            Which describes the task.

             Operator Overloading is a Compile Time Polymorphism in which the operator is
             Overloaded to provide the special meaning to the user defined datatype.

Syntax: return_type classname :: operator op(arg..)
               {
               //statements
               }

----------------------------------------------------------------------------------------------------------------------

31)What are the Operators that can be Overloaded by Member functions ?
   
          a) = (Assignment)
          b)( ) (Function Call)
          c)[ ] (SubScripting)
          d) --> (Arrow)

-----------------------------------------------------------------------------------------------------------------------


32) What are the Operators that can be Overloaded by Friend Function ?

        a) <<  (Insertion)
        b) >> (Extraction)

-----------------------------------------------------------------------------------------------------------------------

33)What are the Operators that can't be Overloaded?

      a) . (dot) member selection Operator
      b) .* (member  pointer selection  Operator)
      c)size of
      d) :: (Scope Resolution Operator)
      e) ? :( Ternary Operator)

Note:

         It is to be noted that if an operator function used to overload a binary operator is a
         member function of a class,then the operator function expects one argument.But,if
         an Operator function is friend to a particular class,then it expects two arguments.

------------------------------------------------------------------------------------------------------------------------

34)What is Virtual Base Class?
       
      1)The Virtual base classes are used to avoid duplication of data.

      2)When the class Parent is made a virtual base class,care is taken by the compiler to
         see that only one copy of the base class parent is inherited.

----------------------------------------------------------------------------------------------------------------------

35)What is Function Overriding?

              Designing a same function in base class as well as in derived class with same
              signature is called as Function Overriding.

---------------------------------------------------------------------------------------------------------------------

36)What is Virtual Destructor ?

                Virtual Destructor is a Destructor that is defined in a base class which make a proper
order of calls of destructor from the derived class to base class when the base class pointer points
to derived class dynamic object.Virtual destructor ensure that the object resources are released
in the reverse order of the object being constructed with respect to inherited object.

------------------------------------------------------------------------------------------------------------------------

37)What is the role of protected access specifier ?

          1) If a class member is protected then it is accessible in the inherited  class.

          2)However,outside both the private and protected members are not accessible.

-----------------------------------------------------------------------------------------------------------------------


38)Explain the purpose of the keyword volatile ?

     1)Declaring a variable volatile directs the compiler that the variable can be changed externally.

     2)Hence avoiding compiler optimization on the variable reference.


-----------------------------------------------------------------------------------------------------------------------

39)What is a pure virtual function ?

       A Virtual Function that is declared but not defined in a base class is reffered to as
       a pure virtual function.(or) A virtual function with no function body and assigned
       with a value zero is called as pure virtual function.

syntax : virtual return type function_name(arg...)=0;

------------------------------------------------------------------------------------------------------------------------

40)What is an Abstract Class ?

           1) A class with atleast one pure virtual function is called as abstract class.

           2)We cannot instantiate an abstract class.
       
           3)Abstract class is reference class to the derived class.


----------------------------------------------------------------------------------------------------------------------

41)What is a Reference Variable ?

     A Reference Variable is an alias name for the existing variable which mean both the variable
    name and reference variable point to the same memory location.Therefor updation on the
    original variable can be achieved using reference variable too.

-----------------------------------------------------------------------------------------------------------------------

42)What is the role of static keyword on class member variable ?

 1)It is like a global variable for its class,it is available to all objects of that class.

 2)Default value of static data members is zero.

 3)Static member variable share a common memory across all the objects created for the
    respective  class.

 4)A static member variable can be referred using the class name itself.


-----------------------------------------------------------------------------------------------------------------------

43)What is Function Overloading ?


 Defining Multiple functions with the same name is called function overloading.These
 functions must differ in their number,order (or) type of arguments.

-----------------------------------------------------------------------------------------------------------------------

44)Explain pointer-this ?

 1)C++ Provides a unique pointer called this pointer.The pointer called this points to the
    objects itself.whenever a member function is called,this pointer is automatically passed
    to the member function as an implicit,in-built argument.

 2)This,is the pointer variable of the compiler which always holds the current active object's
     class.

-----------------------------------------------------------------------------------------------------------------------

45)What is the Namespace ?

 A Name space is a declarative region used to localize global identifiers names to avoid
 name collisions.

-------------------------------------------------------------------------------------------------------------------------

46)Explain Name Mangling ?

 Name Mangling is the process used by c++ compilers,that changes names to every function
 by adding additional information based on function name and its arguments.

Generally programs have atleast a few functions with the same name.Thus name mangling
can be considered as an important aspect in c++.

------------------------------------------------------------------------------------------------------------------------

47)Explain Exception Handling ?

 1)Exceptions,which occurs at run time due to unusual conditions.

 2)To handle such exception,Exception Handling Mechanism is used.

 3)This Mechanism uses three keywords.
 
    i.e.,1)Try
          2)Throw
          3)Catch

4)A try block will throw an exception using throw keyword.

5)Catch block will handle the exception condition which is sent by throw.

6)Syntax :  try
                  {
                   throw exception_occured;
                   }
                   catch(data_type argument)
                   {
                   }

------------------------------------------------------------------------------------------------------------------

48)How can we catch all kind of exceptions in a single catch block ?


 It is used to handle all type of exceptions.

syntax: catch(...)
             {
             
             }

-----------------------------------------------------------------------------------------------------------------------

49)What are the advantages of exception handling ?

 1)Remove error-handling code from software's main line of code.

 2)A Method writer can choose to handle certain exceptions and delegate others to the caller.

 3)An exception that occurs in a function can be handled anywhere in the function call satck.

--------------------------------------------------------------------------------------------------------------------

50)What should be put in a try block ?

 1)Statements that might cause exceptions.

 2)Statements that should be skipped in case of an exception.

---------------------------------------------------------------------------------------------------------------------

51)What are the goals of an exception ?

1)Detect the problem.

2)Warn that an error has come.

3)Accept the error message.

4)Perform accurate action without troubling the user.

-------------------------------------------------------------------------------------------------------------------------

52)What is Template ?

 1)Templates are the features of the programming languages that allow functions and classes to
     operate with generic types.

 2)This allows a function (or) class to work on many different data types without being rewritten
    for each one.

 3)To overcome the disadvantages of the function overloading.

------------------------------------------------------------------------------------------------------------------------

53)When should we use Initializer list in a constructor ?

1)There is a reference variable in class.

2)There is a constant variable in class.

3)There is an object of another class and the other class doesn't have default constructor.

--------------------------------------------------------------------------------------------------------------------------

54)What are the default standard streams in c++ ?

  1)cin
  2)cout
  3)cerr
  4)clog

------------------------------------------------------------------------------------------------------------------------

55)What are Default Arguments ?

   A Default Argument is a function parameter that has a default value provided to it.If the user              doesn't supply a value for this parameter,the default value will be used.If the user does supply
  a value for the default parameter,the user supplied value is provided.

--------------------------------------------------------------------------------------------------------------------------

56)What are the rules for Default Arguments ?

1)A function can have multiple default parameters.

2)All default parameters must be the right most parameters.

3)Default Parameters must be given only in the function prototype and must not be repeated in the         function definition.

--------------------------------------------------------------------------------------------------------------------------

57)What are the advantages of Default Arguments ?

1)They provide greater flexibility.

2)Default arguments can be used to add new parameters to the existing functions.

3)They can also be used to combine similar functions into one.

--------------------------------------------------------------------------------------------------------------------------

58)Difference between C structure and C++ structure ?

1)C Structure having only data members.
   C++ Structure having data members and member functions.

2)Sizeof empty structure is zero bytes in C.
   Sizeof empty structure is one byte in C++.

3)Access Specifiers are not available to protect the data.
   Access Specifiers are available to protect the data.

4)Encapsulation not possible.
   Encapsulation is possible.

-------------------------------------------------------------------------------------------------------------------------

Note:

1)Static member function can access static members
   and can't access Non-Static members

2)Non-Static member function can access static members
  and can access Non-Static members.

-------------------------------------------------------------------------------------------------------------------------

59)Why '=' operator can't be overloaded with friend function ?

  When we don't define the member function for '=' operator,then compiler will supply the default           assignment  operator overloaded function,and if we define the friend function then it becomes
   ambiguity for compiler.

-------------------------------------------------------------------------------------------------------------------------

60)Write the syntax for post increment and pre increment using member function and friend 
     function ?


Post Increment :

     Member Function :

           return type class _name : : operator ++ (int);

    Friend Function :

          friend  return _type operator ++  (arg,int);

Pre Increment :

     Member Function :

           return type  class_name : : operator ++ ( );

     Friend Function :

          friend return_type operator ++ (arg);

-----------------------------------------------------------------------------------------------------------------------

61)Why [ ],( ),-> operators can't be overloaded by friend function ?


       Overloading these operators are having limitations to the language design to maintain
        the data security.

---------------------------------------------------------------------------------------------------------------------

62)Why cout and cin are being passed as reference objects while overloading insertion
      and extraction operator ?

       As the copy constructor and overlaoded assignment operator in the classes 'ostream'
       and 'istream' are declared in the protected section,their objects cout and cin are passed
       as references.

-------------------------------------------------------------------------------------------------------------------

63)Why Constructors and Destructors will not be Inherited to Derived Class ?

    The scope of constructors and Destructors are belongs to same class to intialize and
     deintialize the data members of same class.

-----------------------------------------------------------------------------------------------------------------------

64)Define Binding ?

       Binding refers to the process which is used to convert identifiers into machine level
       language address.

-----------------------------------------------------------------------------------------------------------------------

65)What is Compile Time Binding ?

   1)The event that occurs at compile time is nothing but compile time binding .

   2)Compile Time Binding also called as static binding (or) early binding .

----------------------------------------------------------------------------------------------------------------------

66)What is Run Time Binding ?

 1)The event that occurs at run time is nothing but run time binding .

2)Run Time Binding is also called as Dynamic binding (or) Late Binding .

-------------------------------------------------------------------------------------------------------------------------

67)Explain Virtual Table ?

  1) To implement virtual functions,C++ uses a special form of late binding known as
       virtual table created in compile time.

 2)The virtual table is a look up table of addresses of only the virtual functions in the
     corresponding class to resolve the functions with proper function calls.

---------------------------------------------------------------------------------------------------------------------

68)What is the command for how the compiler conversion code is working ?


          C++  filename  -fdump-tree-gimple

---------------------------------------------------------------------------------------------------------------------

69)Difference between delete and delete[] ?

    1) delete is used to release memory which was allocated using new.

    2)delete[] is used to release the memory allocated to an array which was allocated using new[].

----------------------------------------------------------------------------------------------------------------------

70)What is Function Template and Write the syntax for it ?

 Function Templates are special functions that can operate with generic types.This allows us
 to create a function template whose functionality can be adapted to more than one type (or)
 class without repeating the entire code for each type .

 Syntax : template <class type >
                return_type function_type(Type T )
                {

                }

--------------------------------------------------------------------------------------------------------------------

71)What is Class Template and Write the syntax for it ?

  A Class Template provides a specification for generating classes based on parameters.


Syntax :  template  < class type >
                class class name
                {
                 Type T;
                 Type T1;
                 }

------------------------------------------------------------------------------------------------------------------------


72)What are the advantages of Templates ?

   1)Reduced Source Code.

   2)Less disk space needed to store the source files.

   3)Easy to debug the program.

   4)Good Documentability.

---------------------------------------------------------------------------------------------------------------------

73)What is Standard Template Library ?

    1)It is a library of container classes,algorithms and iterators.

    2)STL is a set of template classes used to provide common programming data structures
       and functions such as lists,arrays,stacks.

--------------------------------------------------------------------------------------------------------------------

74)What are the components of STL ?


   1)Containers

   2)Algorithms

   3)Iterators

---------------------------------------------------------------------------------------------------------------------

75)Why Virtual Constructor not Possible ?


 1)Without constructor execution,object won't be created.

2)without object creation,virtual functions can't access.

3)virtual functions cannot access without object.

4)object will not be created without constructor execution.

5)If we made both properties as single.Because of AMBIGUITY it fails to create an object.
   If object is not created,further operations not possible,so,Virtual Constructor not possible.


---------------------------------------------------------------------------------------------------------------------