+ 1

Help!

I am stuck on c++ challenge 49.2 please help me #include <iostream> using namespace std; class TV { public: TV(int h, int w): height(h), width(w) {}; void area() { cout <<height*width; } private: int height; int width; }; int main() { //your code goes here int h; int w; cin>>h; cin>>w; TV obj (h,w); }

28th Sep 2021, 9:15 AM
Boong Bing
12 odpowiedzi
+ 3
You need to call the area function to print out the value obj.area();
28th Sep 2021, 9:49 AM
Myo Thuzar
Myo Thuzar - avatar
+ 3
Rik Wittkopp No no, it's ok , no need to do that,I'm just happy to help Thanks for mentioning me🤗
28th Sep 2021, 11:17 AM
Myo Thuzar
Myo Thuzar - avatar
+ 1
Boong Bing Challenge 49.2 in c++ is called "Chirp Chirp". Can you please confirm the lesson / challenge number?
28th Sep 2021, 9:21 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Boong Bing I suspect Myo Thuzar gave you a better answer
28th Sep 2021, 9:52 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Boong Bing Yep, confirmed! Myo Thuzar has given you an exact answer int main() { //your code goes here int h; int w; cin>>h; cin>>w; TV obj(h,w); obj.area(); }
28th Sep 2021, 9:56 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Boong Bing Give best answer to Myo Thuzar He solved it!
28th Sep 2021, 11:15 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Thank You Myo Thuzar
4th Oct 2021, 1:08 PM
Boong Bing
0
60.2
28th Sep 2021, 9:22 AM
Boong Bing
0
Please specify the relevant language (C++) in the tags ☝ https://code.sololearn.com/W3uiji9X28C1/?ref=app
28th Sep 2021, 9:32 AM
Ipang
0
Boong Bing Can you confirm that you haven't altered the code above the section which says // Your code goes here
28th Sep 2021, 9:36 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
I am not sure of what you have done prior to posting, or what the original code looked like, but maybe this can help you #include <iostream> using namespace std; class TV { public: TV(int h, int w); private: int height; int width; }; TV::TV(int h, int w): height(h),width(w){ cout << height * width; } int main() { //your code goes here int h,w; cin >> h >> w; TV(h,w); }
28th Sep 2021, 9:51 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Thanks I appreciate all your help!
28th Sep 2021, 10:56 AM
Boong Bing