11.
What will be the output of the following C++ code?
#include <iostream>
#include <complex>
using namespace std;
int main()
{
    complex<double> c_double(2, 3);
    complex<int> c_int(4, 5);
    c_double *= 2;
    c_double = c_int;
    cout << c_double;
    return 0;
}

14.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int operate (int a, int b)
{
    return (a * b);
}
float operate (float a, float b)
{
    return (a / b);
}
int main ()
{
    int x = 5, y = 2;
    float n = 5.0, m = 2.0;
    cout << operate (x, y);
    cout << operate (n, m);
    return 0;
}

15.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Box
{
    public :
    double length;
    double breadth;
    double height;
};
int main( )
{
    Box Box1;
    double volume;
    Box1.height = 5;
    Box1.length = 6;
    Box1.breadth = 7.1;
    volume = Box1.height * Box1.length * Box1.breadth;
    cout << "Volume of Box1 : " << volume <<endl;
    return 0;
}

17.
Identify the correct statement.

18.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class sample 
{
    int width, height;
    public:
    void set_values (int, int);
    int area () {return (width * height);}
    friend sample duplicate (sample);
};
void sample::set_values (int a, int b) 
{
    width = a;
    height = b;
}
sample duplicate (sample rectparam)
{
    sample rectres;
    rectres.width = rectparam.width * 2;
    rectres.height = rectparam.height * 2;
    return (rectres);
}  
int main ()  
{
    sample rect, rectb;
    rect.set_values (2, 3);
    rectb = duplicate (rect);
    cout << rectb.area();
    return 0;
}

20.
Pick the incorrect statement about inline functions in C++?

Read More Section(Classes and Objects in C plus plus)

Each Section contains maximum 100 MCQs question on Classes and Objects in C plus plus. To get more questions visit other sections.