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
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 :)
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;
}