+ 2
Write a c++ Program to find the area of square.... Use friend function and constructor and function to find the area also print
Please help me if you can...
11 ответов
+ 17
~ swim ~ Yes,😊 that's right!👍
+ 16
Hello, 😊
If you need help you can post the code you are struggling with!
• SEARCH for similar QUESTIONS or ANSWERS before posting
• Include relevant TAGS
• https://www.sololearn.com/post/75089/?ref=app
• https://code.sololearn.com/WvG0MJq2dQ6y/
+ 1
~ swim ~ thanks bro.. I get it
0
~ swim ~ I'm stuck.. Can you write a program to understand me?
0
~ swim ~ i will send message for you ok?
0
~ swim ~
#include<iostream>
using namespace std ;
class square ;
class rectangle {
int w,l;
public : rectangle(int x ,int y ):w(x),l(y) {}
int area() { return w*l ; }
friend void area ( rectangle r , square s) ;
};
class square {
int s ;
public :
square ( int x) : s(x) {}
friend void area (rectangle r , square s ) ;
};
void area ( rectangle r , square s) {
int areaa ;
r.areaa=r.w*r.l ;
r.areaa= s.s*s.s;
}
// I HAVE MISTAKES IN THIS FUNCTION ... PLAEASE CORRECT IT
void print ()
{
cout<<"rectangle"<<r.area;
}
int main ()
{
recangle r ( 5,6);
square s(5);
area (r,s);
print()
}