ExamVeda
Login
Home
Classes and Objects in C plus plus
?

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Rect
{
    int x, y;
    public:
    void set_values (int,int);
    int area ()
    {
        return (x * y);
    }
};
void Rect::set_values (int a, int b) 
{
    x = a;
    y = b;
}
int main ()
{
    Rect recta, rectb;
    recta.set_values (5, 6);
    rectb.set_values (7, 6);
    cout << "recta area: " << recta.area();
    cout << "rectb area: " << rectb.area();
    return 0;
}

Answer & Solution
Correct Answer: Option A
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.