-
-
-
Inheritance in C++
While doing inheritance in C++, one thing that is not inherited is what?
-
C/C++ black screen opens and closes
While executing a program in C++, it happens the black screen opens and closes automatically without displaying the output(program is correct). How to recover from this situation?
-
Read the following code and then implement the following parts:
Read the following code and then implement the following parts:
class Point {
public int xCoordinate;
public int yCoordinate;
}
1. Derive a class from Point and call it DerivedPoint, the new class will contain two constructors, the first one takes no arguments, it assigns the point to the point (1,1) and the second constructor takes two parameters... -
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.
-
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 ...
-
-
-
-
-
-
-
What does this function do:
What does this function do:string f(const string &x) { return x.empty()? x : f(x.substr(1)) + x[0];}What does this piece of code perform:char *a=...., *b=....;while(*b++ = *a++);
-
C++ Interview Questions
Ans