[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Technical Interview Questions and Answers :: C++

    21 / 187

    What are "VTABLE" and "VPTR" ?
    Answer:

    The virtual table(vtable) is a lookup table of functions used to resolve function calls in a dynamic/late binding manner. vPtr is set (automatically) when a class instance is created so that it points to the virtual table for that class. vPtr is inherited by derived classes,

    Please Login First :

    22 / 187

    What is static member function and explain its characteristics
    Answer:

    A member function that is declared static has following property,
    • A static function can have access to only other static members declared in the same class.
    • A static member function can be called using the same class name as follows
    class_name:: function_name;

    Please Login First :

    23 / 187

    What Is Inheritance? What is the diamond problem that can occur with multiple inheritance? Explain an example.
    Answer:

    Inheritence is deriving parent(base) class properties to derived class.


    The Diamond Problem :


        A


       /  \


      B   C


       \   /


        D


    Now Class B

    Please Login First :

    24 / 187

    List the types of inheritance supported in C++.
    Answer:

    There are 5 forms available, namely
    • Single inheritance: A derived class with only one base class
    • Multiple inheritance: A derived class with only several base class
    • Hierarchical inheritance: The traits one class may be inherited by more than one class
    • Multilevel inheritance:
    • Hybrid inheritance: it is a combination of multiple and hierarchical inheritance.

    Please Login First :

    25 / 187

    What is Copy Constructor? Write a program using it.
    Answer:

    Copy constructor is used to declare and initialize an object from another object.
    For example, the statement
    Integer I2(I1);
    Would define the object I2 and at the same time initialize it to the values of I1. another form of this statement is integer I2=I1;
    The process of initializing through a copy constructor is known as copy initialization. A copy constructor takes a reference to an object of the same class as itself as an argument.

    Please Login First :

    26 / 187

    Function overloading VS Operator Overloading
    OR
    What is the difference between function overloading and operator overloading? And what are the advantage of it.
    Answer:

    function overloading: instead of writing the different functions to perform same actions we write same function name with different number of parameters of different types of parameters it is called function overloading.

    advantages of function overloading- improve code

    Please Login First :

    27 / 187

    Explain about Friend function and friend class.
    Answer:

    Friend Function:
    A friend function can access a class private data, even though it is not a member function of the class. This is useful when one function must have access to two or more unrelated classes and when an overloaded operator must use, on its left side, a value of a class other than one of which it is a member. Friends are also used to facilitate functional notation.

    Friend Class:
    It is possible to grant a non-member function access to the private members of a class by using a friend. A friend function has access to all private and protected members of the class for which it is a friend.

    Please Login First :

    28 / 187

    Point out difference Malloc() vs new and Delete vs Free
    Answer:

    No Discussion on this question yet!

    Please Login First :

    29 / 187

    What are difference/comman points Structure vs class in C++
    Answer:

    No Discussion on this question yet!

    Please Login First :

    30 / 187

    Why the size of empty Class is one byte?
    OR
    What will the sizeof empty Class ?
    Answer:

    No Discussion on this question yet!

    Please Login First :