I recently took my C++ midterm, and I want to make sure I know how to do the things that it asked me to do. Can some people help explain to me how this would be done?
Create a class Tweet with a constructor, accessor, and mutator functions where Tweet accesses strings Subject and Message, and a mutator that appends subject to message.
I think i know how to do this part
This probably isn't right, can someone help me with creating a class, specifically this one?Code:class Tweet { Public: Tweet(); Tweet(string subject, string message);//constructor Tpend(string subject, string message); Private: string subject; string message; }
Then it asked to create the functions for the class. I think i know how to do this one, but then again I may be wrong:
The other part of the question was to create an int main using tpend and addTweet (from a class it gave) to add a message with it's subject inside vector v.Code:Tweet::Tweet() { this->subject = subject; this->message = message; } Tweet::Tweet(string subject, string message) { } Tweet::Tpend(string subject, string message) { message = subject + ' ' + message; }
addTweet just does a simple v.push_back(message);Code:int main() { string mess = "Hello!"; string subj = "Twitter"; Tweet t(subj, mess); t.Tpend(subj, mess); vector<string>v; t.addtweet(mess, v); }
I know this is a lot I'm asking, but just some help would be great! Thanks =)



LinkBack URL
About LinkBacks


