-
Invoke the virtual toString() function
To invoke the virtual toString() function defined in GeometricObject from a Circle object c, use :A. ((GeometricObject*)c)->toString();B. c.super.toString()C. (GeometricObject*)c->toString();D. c->GeometricObject::toString()
-
Base Class Pointer with Derived Object
Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived object, calling of that virtual method will result in which method being called?
-
Static Polymorphism
What is Static Polymorphism? Give its syntax and simple example.
-
-
-
-
Permutations
Write a program to display all possible permutations of a given input string--if the string contains duplicate characters, you may have multiple repeated results. Here is a sample for the input cat
cat,cta,act,atc,tac,tcaWhat 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.
What is a scope resolution operator?
A scope resolution operator (::), can be used to define the member functions of a class outside the class.
What is virtual class and friend class?
Friend classes are used when two or more classes are designed to work together and need access to each other's implementation in ways that the rest of the world shouldn't be allowed to have. In other words, they help keep private things private. For instance, it may be desirable for class DatabaseCursor to have more privilege to the internals of class Database than main() has.
What is virtual constructors/destructors?
Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object. There is a simple solution to this problem – declare a virtual base-class destructor. This makes all derived-class destructors virtual even...
Private Inheritance question
Hi I very recently did the C++ online Quiz and was surprised to find that my answer (1) to the following question (below) was incorrect. Is there something I am missing here, or is the answer incorrect. I thought this was the point of Private. "Always inaccessible regardless or derivation access".Apparently (3) in the correct answer! according to the quiz!The private member in derived class ...
Difference between realloc() and free()?
The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur. The realloc subroutine changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new...
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.
What is the need /use of function overloading
Hint FO is mechanism in which two functions r having same name with diff no. of arguments.
Ans