What will be printed as a result of execution of the following code?
#include <iostream>

class A
{
     public:
            A() { }
            operator int() { return 10; };
            operator float() const { return 2.0; };
};

class B
{
     public:
            B() { }
            operator int() const { return 5; };
            operator float() { return 1.0; };
};

int main()
{
     A a;
     B b;
     std::cout << a + b << std::endl;
     return 0;
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
C++ quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes