I need some constructors created in C++ linux that follow the following header f
ID: 3908714 • Letter: I
Question
I need some constructors created in C++ linux that follow the following header file and conditions.
class Message public: // constructors /* Sets Message instance's body to empty string Message (); /* Sets Message instance's body to char array parameter */ Message(const char body[]); /* Sets Message instance's body to string parameter.* Message (const std::string& body);Explanation / Answer
#include #include using namespace std; class Message { public: Message(); Message(const char body[]); Message(const std::string& body); private: string body; }; Message::Message() { this->body = ""; } Message::Message(const char body[]) { int i=0; this->body = ""; while(body[i]) { this->body += body[i]; i++; } } Message::Message(const std::string& body) { for(int i = 0; i body += body[i]; } } int main() { return 0; }Related 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.