With the coding below ,Complete the part labelled ‘//2 a) i’, write the constructor function that outputs “~~Building Created~~” and labelled //2 a) ii’, write the codes to define function findLargest(…). This function will receive an array of 5 Room objects and display the area width x length) of each object. The largest room area will be determined and displayed accordingly. #include using namespace std; class Room { int width, length; public: // 2 a)to complete void setData (int L, int T) { width = L; length = T; } friend class Building; } ; class Building { string name; public: Building() { name = "Building"; cout<<"----Buiding name : "<>x>>y; r[i]. setData(x,y); i++; } B1.findLargest(r); return 0; }
With the coding below ,Complete the part labelled ‘//2 a) i’, write the constructor function that outputs “~~Building Created~~” and labelled //2 a) ii’, write the codes to define function findLargest(…). This function will receive an array of 5 Room objects and display the area width x length) of each object. The largest room area will be determined and displayed accordingly.
#include <iostream>
using namespace std;
class Room
{ int width, length;
public:
// 2 a)to complete
void setData (int L, int T)
{ width = L;
length = T;
}
friend class Building;
} ;
class Building
{ string name;
public:
Building()
{ name = "Building";
cout<<"----Buiding name : "<<name<<"-------"<<endl;
}
// 2 a)to complete
};
int main()
{ Building B1;
Room r[5];
int i = 0, x, y;
while( i < 5 )
{
cout<<"Enter the tables' width and length :\n";
cin>>x>>y;
r[i]. setData(x,y);
i++;
}
B1.findLargest(r);
return 0;
}
Step by step
Solved in 2 steps with 1 images