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 sample;
class sample1 
{
    int width, height;
    public:
    int area ()
    {
        return (width * height);}
        void convert (sample a);
    };
class sample 
{
    private:
    int side;
    public:
    void set_side (int a)
    { 
        side = a;
    }
    friend class sample1;
};
void sample1::convert (sample a) 
{
    width = a.side;
    height = a.side;
}
int main () 
{
    sample sqr;
    sample1 rect;
    sqr.set_side(6);
    rect.convert(sqr);
    cout << rect.area();
    return 0;
}

Answer & Solution
Correct Answer: Option D
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.