CPP INTERVIEW QUESTIONS

1)Difference between C and C++?

  a) C is STRUCTURAL language and C++ is PROCEDURAL

     and OBJECT-ORIENTED.

  b) In the case of C, Importance is given to the steps (or) procedure

     of the program while C++ focuses on the data rather than the process.

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

  d) 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.

  e) In C++ Mapping between data & function is possible

        through objects but in C, it is difficult.

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

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

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

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

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

  k) In C++ NEW and DELETE operators are used for

      Dynamic memory allocation. In C, Library functions are

      used to allocate DMA.

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

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

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

2)Difference between Printf Scanf over cout & cin?


a) Printf and Scanf is Library functions but cout and cin

    are objects.

b) Printf and Scanf do need format specifier, cout and cin

     don't require format specifier.

c)Printf and Scanf doesn't support user-defined variables

  directly to print and scan the data members but cout

 and cin support user-defined variables directly to scan

 and print the data members with the help of

 operator overloading.


3)Difference between Reference and Pointer?

 a) The pointer will get separate memory.

    The reference will not get separate memory.

 b) The pointer may (or) may not be Initialized

     The reference variable must be Initialized.

 c) Its lifetime pointer can point to any variable.

     Its lifetime Reference variable can refer to only one variable.

 d) Null Pointer possible.

     Null Reference not possible.

 e) Pointer Explicitly will get Dereferenced.

     Reference Implicitly will get Dereference.

 f) Pointer to Pointer Possible.

    Reference to Reference not possible.

 g) An array of Pointers is Possible.

    An array of references not possible


4)Difference between Macro and Inline Function?

    

a)    Macro is a Single Instruction which is

replaced with Multiple Instructions.

       A function call is replaced with Definition.

b)    It is always defined at the start of the program.

      It can be defined inside (or) outside the class.

c)    It evaluates the argument each time it is used

      in the code.

      It evaluates the argument only once.

d)    Macro is a Mandatory statement.

      It is requesting the compiler If possible replace

      otherwise No.

e)    Macros are expanded by the preprocessor.

      Inline Functions are parsed by the Translator.

5)Difference between Malloc and New?

a)    Malloc is a Function.

           New is an Operator.

b)    Malloc needs the size of operator

           New doesn't require the size of operator.

c)    Memory Initialization Not Possible

           Memory Initialization Possible.

d)    On success, malloc function returns a void pointer

           On success, the new operator returns the exact pointer type.

e)    On Failure, malloc returns Zero.

           On Failure new throw an Exception.

f)     It needs typecasting.

           The new operator doesn't need (or) required typecasting

g)    Malloc function overloading not possible

           New operator overloading possible.

h)    Up on Object creation, the malloc function doesn't

      call the constructor.

           Up on Object creation, the new operator does call the

           constructor.

 6)Difference between Delete and Free?

a)    Free is a function

       Delete is an operator.  

b)    Free Function Overloading Not Possible.

       Delete Operator Overloading possible.  

c)    Free Function doesn't call destructor upon object destroying

      The delete operator does call destructor up on object destroying.

 7)Difference between the Member Function and Friend Function?

a)    The member function belongs to the same class.

       Friend function does not belong to the same class.

b)    The member function will have this pointer.

       The friend function doesn't have this pointer.

c)    The member function must call through an object.

       A friend function can Invoke directly.

d)    A member function can access the data member

       without an object.

      A friend's function can access the data members

      of a class through the object.

e)    The scope of a member function is limited to the same class.

      A friend's function is limited to n number of classes.

8)Difference between Constructor and Member function?

a)    The constructor's name is having the same name as

            the class name.

            A member function can have any legal Identifier name.

b)    Constructors don't have any return type.

            A member function can have a return type.

c)     Constructors are used to Initializing an Object.

             Member functions are used to access/modify the data.

d)    Constructor Constructing an Object.

            Member function not Constructing an object.

e)    The constructor will call automatically whenever an

            object gets created

             Member function will invoke Explicitly.

f)      In its lifetime of an object, the constructor will execute

             only one time.

             The member function will execute n number of times

               to that object.

g)    Addresses of the constructor cannot be referred.

           Member function Address can be referred.

h)     Member wise Initialization possible only through the constructor.

            Member wise Initialization not possible by member function.

i)     A constructor cannot be virtual.

           A member function can be virtual.

j)      Constructors cannot be Inherited.

            Member functions can be Inherited.

k)     Friend Constructor not possible.

             A member function can be a friend.

 9)Difference between Constructor and Destructor?

a)    The constructor is having the same name as the class name.

            Destructor is also having the same name as a class name

             but prefix with Tild (~) symbol.

b)     Constructor Constructing an Object.

             Destructor Destroying an Object.

c)    Constructor Can Be Overloaded.

            Destructor Cannot Be Overloaded.

d)    The constructor can have the arguments,

            Destructors cannot have arguments.

e)    A constructor cannot be Virtual.

           Destructors can be Virtual.

 

10)Difference between Shallow Copy and Deep Copy?

 Shallow Copy

 

a)    Copy one object data to another object with the help 

 

           of compiler provided copy constructor (or) 

 

           Assignment overloaded operator is called a shallow copy.

 

b)    Shallow copy is also called as Member wise copy

 

c)    In shallow copy, both objects are pointing to the

 

           same memory location.

 

d)    In shallow copy, if one object is modified. It will

 

Be affected by another object automatically.

 

e)     A shallow copy will not support an object

 

 which contains a dynamically allocated pointer.


 Deep Copy

 

a)    Copy one object data to another object with the

 

Help of a user-provided copy constructor (or)

 

Assignment overloaded operator is called a Deep copy

 

b)     A deep copy will support an object which contains

 

            a dynamically allocated pointer.

 

c)    In a deep copy, both objects are pointing to different

 

           memory locations.

 

d)    In a deep copy, if one object is modified it will not 

 

           affect another object.

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

a)    Data abstraction can be used to provide security for data

         from unauthorized methods.

b)    It refers to the act of representing essential features and

         hiding the background details.

  Ex: -1) ATM machine

          2)Facebook

          3)A man driving a car

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

a)      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 are 

 

               known as "BASE CLASS".


b)      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

 

             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)Multipath 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?

a) Encapsulation is a mechanism that binds together code and

    data into a single unit called class, and that keeps both safe

     from outside Interference and Misuse.

b) Wrapping of data and function into a single unit is

    called   Encapsulation.

c)The procedure to bind the data and functions as a single

    unit is called Encapsulation.

Ex: - 1) Capsule which is mixed with several medicines.

         2)Any C++ program where you can implement a class

            with a public and private member is an example

             of encapsulation.

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

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

b) In C++, Polymorphism is divided into two types

i)Compile Time Polymorphism

        a) Function Overloading

        b) Operator Overloading

ii)Run Time Polymorphism

a)    Virtual Functions.

  Ex: -You have a smartphone 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 there

        approach  is different.

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

 

a)    1) Class is an advanced version of the structure.

 

       2) Class is a collection of data members and

         

           Member functions.

 

           Data is a member of a class is called Data Member.

 

           The function is a member of a class is called 

 

           Member function.

 

b)    1) Object is a variable of a class.

 

        2) The object is an instance of a class.

 

        3)The object is the Physical Existence of a Class.

 

        4)The object is a real-world Entity of a Class.

 

        5) Any real-world entity which can have some 

 

            characteristics of which can perform

 

            some tasks are called an Object.

 

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

 

d)    An example is the Class of cars

 

e)     In the above example of class Car, the data member 

 

         will be speed limit, mileage, etc and member functions

 

         can apply brakes, increase speed, etc.

 

f)      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 are 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) The address of the 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

           is done properly.

      b)   Memory Allocation is done by OS.

      c)   Memory Initialization is done by Constructor.

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

      e)   A constructor is executing before an object Creation.

      f)    If Constructor execution fails, then the object will not

            be created.


21)What is the Default Constructor?

a) A Constructor that does not accept any Parameter is called

     Default Constructor.

b) When a Constructor is not explicitly declared in a class, a

     default Constructor is added and is invoked during

     object initialization 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 ?

a)    A Copy Constructor is a Special Case of Constructors,

       Used to make a Copy of One Class objects and initialize

        it by using another object of the same class type.

b)    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?

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 the creation of an object. But there are 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

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 the 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)A destructor must 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 a recursive call which leads to segmentation fault during

run time. To avoid this problem, the Compiler itself is restricted

not to take the argument as a non-reference.

 28)What is Constant Member Function?

A 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 referred to as

 

  Operator Overloading.

 

  An Operator can be Overloaded by Creating a Special

 

  Function is called the 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 a friend to a particular class, then it expects two

 

 arguments.

 34)What is Virtual Base Class?

a) Virtual base classes are used to avoid duplication of data.

b) 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 the same function in the base class as

well as in derived class with the same signature

 is called Function Overriding.

 36)What is Virtual Destructor?

Virtual Destructor is a Destructor that is defined in a base

 class that makes a proper order of calls of destructor from

 the derived class to base class when the base class pointer

points to the derived class dynamic object. Virtual destructor

ensures that the object resources are released in the reverse

order of the object being constructed to the inherited object.

37)What is the role of protected access specifier?

 a) If a class member is protected then it is accessible

     in the inherited class.

 b) However, outside both the private and protected

    members are not accessible..

38)Explain the purpose of the keyword volatile?

  a) Declaring a variable volatile directs the compiler that

      the variable can be changed externally.

 b) 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

 

referred to as a pure virtual function (or) A virtual function with no

 

function body and assigned with a value zero is called a pure virtual

 

function.

 

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

 

 40)What is an Abstract Class?

a) A class with at least one pure virtual function is called

    an abstract class.

b) We cannot instantiate an abstract class.

c)An abstract class is a reference class to the derived class.

 41)What is a Reference Variable?

A Reference Variable is an alias name for the existing variable which

 means both the variable name and reference variable point to the

 same memory location. Therefore, updating on the original

 variable can be achieved using the reference variable too.

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

a)    It is like a global variable for its class, it is available to

           all objects of that class.

     b)  The default value of static data members is zero.

     c)  The static member variable shares a common memory

           across all the objects created for the respective class.

    d)   A static member variable can be referred to 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?

a) C++ Provides a unique pointer called this pointer. The

   pointer called this point 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.

b) This is the pointer variable of the compiler which always

     holds the currently active object's class

 45)What is the Namespace?

The namespace 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 the function name and its arguments.

 

Generally, programs have at least a few functions with the

same name. Thus name mangling can be considered an

important aspect in c++.

 47)Explain Exception Handling?

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

 

b) To handle such an exception, the Exception Handling

 

   This mechanism is used.

 

c)This Mechanism uses three keywords.

 

      1)Try

 

     2)Throw

 

     3)Catch

 

d)A try block will throw an exception using the throw keyword.

 

e) The catch block will handle the exception condition which

 

    is sent by throw.

 

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 types of exceptions.

syntax:

catch(...)

{

 }


 
49)What are the advantages of exception handling?

a) Remove error-handling code from the software's main line

     of code.

b) A Method writer can choose to handle certain exceptions

     and delegate others to the caller.

c)An exception that occurs in a function can be handled

   anywhere in the function call stack

 50)What should be put in a try block?

 a) Statements that might cause exceptions.

 b)Statements should be skipped in case of an exception.

 51)What are the goals of an exception?

a) Detect the problem.

b) Warn that an error has come.

c)Accept the error message.

d)Perform accurate action without troubling the user.


52)What is Template ?

a) Templates are the features of the programming languages

    that allow functions and classes to operate with generic types.

b) This allows a function (or) class to work on many different

     data types without being rewritten for each one.

c) To overcome the disadvantages of function overloading.

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

 a) There is a reference variable in a class.

 b) There is a constant variable in a class.

 c)There is an object of another class and the other class

    doesn't have a default constructor.

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

 a) cin  b)court c)cerr d)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?

a) A function can have multiple default parameters.

b) All default parameters must be the rightmost parameters.

c)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?

a) They provide greater flexibility.

b) Default arguments can be used to add new parameters

    to the existing functions.

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

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

a) C Structure having only data members.

  C++ Structure having data members and member functions.

b) The size of empty the structure is zero bytes in C.

  Size of an empty structure is one byte in C++.

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

  Access Specifiers are available to protect the data.

d)Encapsulation not possible.

  Encapsulation is possible.

 

Note:

 

a) A static member function can access static members

 

  and can't access Non-Static members

 

b) A 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 the

 compiler will supply the default assignment operator overloaded

 function, and if we define the friend function then it becomes

 ambiguity for the 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 data security.

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

      and extraction operator?

As the copy constructor and overloaded assignment operator

in the classes 'ostream' and 'istream' is 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 belong to the same

 class to initialize and deintialize the data members of the

 same class.

 64)Define Binding?

  Binding refers to the process which is used to convert

  identifiers into machine level language addresses.

 65)What is Compile Time Binding?

    a) The event that occurs at compile time is nothing but

        compile time binding.

   b) Compile Time Binding is also called static binding

       (or) early binding.

 66)What is Run Time Binding?

a) The event that occurs at run time is nothing but run

    time-binding.

b) Run Time Binding is also called as Dynamic binding

   (or) Late Binding.

 67)Explain Virtual Table?

a) To implement virtual functions, C++ uses a special form

    of late binding known as the virtual table created in

    compile time.

b) The virtual table is a lookup table of addresses of only the

     virtual functions in the corresponding class to resolve

     the functions with the 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[] ?

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

b) 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) a 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 ?

  a) Reduced Source Code.

  b) Less disk space is needed to store the source files.

  c)Easy to debug the program.

  d)Good Documentability.

 73)What is the Standard Template Library?

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

  b) 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?

 a)Containers

 b)Algorithms

 c)Iterators

 75)Why Virtual Constructor not Possible?

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

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

c)virtual functions cannot access without an object.

d)object will not be created without constructor execution.

e) If we made both properties as single. Because of AMBIGUITY,

   it fails to create an object. If the object is not created,

  further operations not possible.so, Virtual Constructor

  not possible.



76)What is Multithreading in c++?

a) A program can execute multiple instructions at the same time.

b) A Mechanism by which a single set of code can be used by

    several threads at different stages of execution.

c)The ability to execute different parts of a program simultaneously.

d)A multi-threaded program contains two (or) more parts that can

   run concurrently. Each part of such a program is called a thread,

   and each thread defines a separate path of execution.

 77)What is Multi-Tasking?

a)    It is the concept of performing multiple tasks (or) processes

over a certain period of time by executing them concurrently.

      b)  It does not automatically imply multi-threading.

      c) On a single processor system, multitasking is implemented

          by time slicing and the CPU switches between different tasks.

 78)What are the types of Multitasking?

In general, there two types of multitasking

a) process-based

b) thread-based

process-based multitasking handles the concurrent execution of programs.

thread-based multitasking deals with the concurrent execution of pieces of the same program.

 79)Give an application of Multi-Threading?

A simple example could be a word document in which spell check

response to keyboard, formatting, etc happens at the

same time (or) concurrently.

80)What is a Container in STL ?

Containers are objects that store data, define the names

 in which data will be stored and are implemented using

 templates.

 81)What are the types of Containers in C++?

1)Sequence Container

 

It implements data structures which can be accessed sequentially.

 

 a) array: static contiguous array

 

 b) Vector: dynamic contiguous array

 

 c)deque: Double-ended queue

 

 d)list: Doubly Linked List

 

 e) forward list: Single Linked List

 

2)Associative Container

 

 It implements a sorted data structure that can be quickly searched.

 

a)      Set: Collection of unique keys

 

 b) Map: Collection of Key-value pairs, sorted by keys, 

              keys are unique

 

c)Multiset: Collection of keys, sorted by keys

 

d)MultiMap: Collection of key-value pairs sorted by keys.

 

3)Unordered Associative Container

 

1)Unordered Set 

 

2)Unordered Multi Set

 

3)Unordered Map

 

4)Unordered MultiMap

  

 82)What are container adaptors?

It provides a different interface for the sequential container.

a) stack: It adapts a container to provide a stack

b) queue: It adapts a container to provide a queue.

c)priority queue: It adapts a container to provide a priority queue.

 83)  What is meant by Iterator?

a) Data stored in containers are accessed by Iterators.

b) It is used to point at the memory addresses of STL containers.

c)They are primarily used in sequence of numbers, characters.

d)They reduce the complexity and execution time of the program.

 84)What is meant by an algorithm?

a)  the algorithm works on Iterators.

b) Algorithms are components that perform algorithmic

   operations on containers and other sequences.