Answered Questions

  • What is a template?

    Templates allow to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until certain point they fulfill the functionality of a macro. Its prototype is any of the two following ones: template identifier> function_declaration; template identifier> function_declaration; The only difference between...

    MCBod

    • Mar 31st, 2010

    A template is a function that is defined without template parameters, being parameters that have an undefined type. The logic of the function must be executable for all possible data types e.g. using ...

  • What do you mean by inline function?  

     The idea behind inline functions is to insert the code of a called function at the point where the function is called. If done carefully, this can improve the application's performance in exchange for increased compile time and possibly (but not always) an increase in the size of the generated binary executables.  

    Sampada Wadkar

    • Apr 9th, 2012

    An Inline function is a function that is expanded in line when it is invoked. That is compiler replaces the function call with the corresponding function code.. :)

    Code
    1. CO06203

    MCBod

    • Mar 31st, 2010

    An inline function is a function where a copy of the logic is embedded in the application at each the point where it is called by the compiler. This basically allows a reduced overhead in function dereferencing

  • What is function overloading and operator overloading?

      Function overloading: C++ enables several functions of the same name to be defined, as long as these functions have different sets of parameters (at least as far as their types are concerned). This capability is called function overloading. When an overloaded function is called, the C++ compiler selects the proper function by examining the number, types and order of the arguments in the call....

    MCBod

    • Mar 31st, 2010

    Overloading basically refers to the provision of second of subsequent version of the same function or operator based on different parameters.In terms of functions each different version of t...

  • What is polymorphism? Explain with an example?  

    "Poly" means "many" and "morph" means "form". Polymorphism is the ability of an object (or reference) to assume (be replaced by) or become many different forms of object. Example: function overloading, function overriding, virtual functions. Another example can be a plus ‘+’ sign, used for adding two integers or for using it to concatenate two strings.  

    Tech4 u

    • Jul 22nd, 2017

    The ability to define more than one function with the same name is called polymorphism.

    This provides the facility of sending the same message to objects of parent class and objects of the sub classes.

    sunil

    • Feb 26th, 2017

    Several forms having same name is called polymorphism.
    We have two types of polymorphism in C++.
    1) Compile time Polymorphism or function overloading
    2) Runtime Polymorphism or function overriding

  • What are virtual functions?

    A virtual function allows derived classes to replace the implementation provided by the base class. The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class, even if the object is accessed by a base pointer rather than a derived pointer. This allows algorithms in the base class to be replaced in the derived class, even if users don't...

    MCBod

    • Mar 31st, 2010

    A virtual function is a member function of a class fro which it expects child functions to provide their own implementations. My specifiying the function as virtual we allow polymorphism to take place...

  • What is friend function?

    As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private and protected members. A friend function is not a member of the class. But it must be listed in the class definition.

    MCBod

    • Mar 31st, 2010

    A friend function is a special function that has been granted access to the priovate members of a specific class. The class itself is responsible for declaring the friendship. It is nto affected by in...