Question
Hello learning C++ here. So here is my code so far in c++. I know its bit messy but bear with me. I want it
Hello learning C++ here.
So here is my code so far in c++.
I know its bit messy but bear with me.
I want it to display the new information I put in for new "artist" but it only display the new artists name only.
It does not display the year or the song name at the end.
wanted to figure out what I'm doing wrong?
I'm assuming its my vector that I created but cant figure out how I can change it to display all the new information I give it.
Also if you could also help me with the delete selected objects and need to figure out the program to continue to run until they are done that would be great.
#include #include #include
using namespace std;
class Artist { private: //Member Variables string name; int year; string song; public: ////Overload Constructor //Artist(string, int, string);
//Accessor Functions string getArtistName() const { return name; } int getYearBorn() const { return year; } string getSong() const { return song; }
//Mutator Functions void setArtist(string name, int year, string song) { Artist::name = name; Artist::year = year; Artist::song = song; } //Destructor ~Artist(); };
void changeArtist(Artist& artists); vector getArtist(const vector& artists);
int main() { Artist artist1; artist1.setArtist("Chris Brown", 1989, "Run it!"); cout
Artist artist2; artist2.setArtist("T-Pain",1980,"Blah"); cout
Artist artist3; artist3.setArtist("Justin Bieber",1993,"Cool"); cout
changeArtist(artist1); cout
changeArtist(artist2); cout
changeArtist(artist3); cout
vector artists; artists.push_back(artist1); artists.push_back(artist2); artists.push_back(artist3);
vector list = getArtist(artists); for (int i = 0; i
void changeArtist(Artist& artists) { string artistName; int yearBorn; string artistSong; cout > artistName; cout > yearBorn; cout > artistSong; artists.setArtist(artistName, yearBorn, artistSong); cout
vector getArtist(const vector& artists) { vector list; for (int i = 0; i
Artist::~Artist(){
}
Instructions: Your job is to create a complete program that defines a class with at least three data members and getter and setter member functions for each, allows the user to create new objects of that class, list the objects created and delete selected objects. The objects of the class should be stored in a vector. Work with your partner to come up with a useful class that a user would want to keep a collection of objects from. This could be books, music, courses, family members, etc. The program must continue running and allowing users to view, add and remove objects until they indicate that they're done. User input does not need to be bulletproofed. The main code must be in top-down format with work broken into separate functions, each function prototyped before main and defined after main. CS Microsoft Visual Studio Debug Console Name: Chris Brown Year born: 1989 Song: Run it! Name: T-Pain Year born: 1980 Song: Blah Name: Justin Bieber Year born: 1993 Song: Cool Enter a new artist info: Example1 Enter year born: 1992 Enter song: Help New artist name: Example1 Year born: 1992 Song: Help Enter a new artist info: Eample2 Enter year born: 1993 Enter song: Me New artist name: Eample2 Year born: 1993 Song: Me Enter a new artist info: Example3 Enter year born: 1990 Enter song: Please New artist name: Examples Year born: 1990 Song: Please Example Eample2 Example C: wUserswYong Documents CS132#Vector of Objects#DebugWVector of Objects.exe (process 29720) exited with code 0. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console Press any key to close this window ... a Need all info showingStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started