Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++: Write a Twitter class that sets the Twitter user first (who is to be followed) and lets the client add up to 5

In C++:

Write a Twitter class that sets the Twitter user first (who is to be followed) and lets the client add up to 5 followers, which will be stored in an array with a capacity of 5. These users/followers could be in the form of string or Profile. (Note that the followers are not stored as users, but as strings or Profiles).

At any time, your main program should be able to remove any user, x from following another user, y (i.e., x is no longer in the array of followers of y). You are free to design your program as you wish as long as you fulfill the following requirements:

Twitter class should be declared as a template class (the template parameter defines how the followers are represented)

Twitter class includes a constructor that initializes the name of the user that is passed. The number of followers starts off at 0.

AddFollower function in Twitter class should be defined correctly. It takes as parameter an object of the template parameter.

RemoveFollower function in Twitter class should be defined correctly. It takes as parameter an object of the template parameter. [

PrintFollowers function in Twitter class should be defined correctly. It displays the name of all the followers. (Remember: each follower is an object of the template parameter. As you will declare Profile struct which can be a template parameter, for the Profile struct, we must overload stream insertion << operator. Now, we can use cout << follower to display the follower).

Submitting a main program that tests the Twitter class as follows:

Twitter object

Twitter object

Whenever any change is made to a Twitter object (like a follower is added, a follower is removed), call PrintFollowers to display the followers of the Twitter object.

Tips:

Your Profile struct definition along with overloaded << operator could look like the following. Note that you define the Profile struct in your main program (not in the header). You may also need to overload the == operator for the RemoveFollower function.

struct Profile {

string userName;

int age;

string state;

ostream& operator << (ostream & output, Profile p) {

output << p.userName;

return output;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Compare levels of resolution in conflict outcomes?

Answered: 1 week ago

Question

Strategies for Managing Conflict Conflict Outcomes?

Answered: 1 week ago