0

I can not do the "PRACTICE EXERCISE the ninth wave" practice in C++ intermidate.

#include <iostream> #include <string> using namespace std; class Painting { public: string say; void painting(string x){ say=x; } }; int main() { string name; cin >> name; Painting painting(name); return 0; } I don't know how to do this, please as quick as possible

30th Aug 2024, 10:44 AM
BĂĄ Anh Nguyễn
BĂĄ Anh Nguyễn - avatar
2 Answers
+ 1
This previous discussion may help you https://www.sololearn.com/en/Discuss/2944538/532-practice-the-ninth-wave P.S. Please try the search feature next time, before submitting new questions :)
30th Aug 2024, 4:53 PM
Ipang
0
#include <iostream> #include <string> using namespace std; class Painting { public: // Constructor that initializes the 'say' member variable Painting(const string& x) : say(x) {} // Member function to display the painting's message void display() const { cout << say << endl; } private: string say; }; int main() { string name; cin >> name; // Create a Painting object and pass 'name' to the constructor Painting painting(name); // Display the painting's message painting.display(); return 0; }
31st Aug 2024, 4:36 PM
Oleksiy Semyanyk
Oleksiy Semyanyk - avatar