Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by Ayush ( 7 years ago )
#include<iostream>

using namespace std;

class B;

class A
{
private:
    int x;
public:
    A(){
        cout << "Enter a number: ";
        cin >> x;
    };
    friend void math(A a, B b);
};

class B
{
private:
    int y;
public:
    B(){
        cout << "Enter another number: ";
        cin >> y;
    };
    friend void math(A a, B b);
};

class Square{
private:
    int side;
public:
    Square(){
        cout << "Enter the sides of the Square: ";
        cin >> side;
    }
    friend class Rectangle;
};

class Rectangle{
private:
    int length, breadth;
public:
    Rectangle(){
        cout << "Enter the length and breadth of the Rectangle: ";
        cin >> length >> breadth;
    }
    void Area(Square sq){
        cout << "Area of Square is: " << sq.side * sq.side << "." << endl;
        cout << "Area of Rectangle is: " << length * breadth << "." << endl;
    }
};

void math(A a, B b){
    cout << "Addition of both the numbers is " << a.x + b.y << "." << endl;
    cout << "Mean of both the numbers is " << (a.x + b.y)/2 << "." << endl;
}

int main(int argc, char const *argv[])
{
    A a;
    B b;
    math(a,b);
    Square s;
    Rectangle r;
    r.Area(s);
    return 0;
}

 

Revise this Paste

Your Name: Code Language: