Examveda

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class A
{
    public:
    A(int n )
    {
        cout << n;
    }
};
class B: public A
{
    public:
    B(int n, double d)
    : A(n)
    {
        cout << d;
    }    
};
class C: public B
{
    public:
    C(int n, double d, char ch)
    : B(n, d)
    {
        cout <<ch;
    }
};
int main()
{
    C c(5, 4.3, 'R');
    return 0;
}

A. 54.3R

B. R4.35

C. 4.3R5

D. R2.6

Answer: Option A


Join The Discussion

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it