Sunday, 14 February 2016

Programming Output(C++)

1. Predict the output of the following code:

#include<iostream>
using namespace std;
class A
{
    public:
        A(int n)
        {
            cout<<n<<endl;
        }
};

class B:public A
{
    public:
        B(int n,double m):A(n)
        {
            cout<<m<<endl;
        }
};

class C:public B
{
    public:
        C(int n,double m,char o):B(n,m)
        {
            cout<<o<<endl;
        }
};

int main()
{
    C object(12,12.21,'s');
    return 0;
}








Answer:
12
12.21
s


No comments:

Post a Comment