Create a class named Frame with two data members of xdim and ydim. Write a const
ID: 3537901 • Letter: C
Question
Create a class named Frame with two data members of xdim and ydim. Write a constructor to initialize two values. Declare a friend class named Display in it. Then declare Display class with one data member bool type named xfirst, constructor passing bool initial value (true or false), and a function named displaydim passing object of Frame to display its xdim first or ydim first. Test both classes by creating object of Frame first, pass it to Display object to display its x and y dimension deppending on the bool initial value.
Explanation / Answer
#include using namespace std; class Frame{ friend class Display; int xdim; int ydim; public: Frame(int a,int b){ xdim=a; ydim=b; } }; class Display{ public: bool xfirst; Display(bool a){ xfirst=a; } void displaydim(Frame obj){ coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.