Hi! Im Working on a project of mines and I cant seem to get this class together.
The class im working on is cd player. It can fast forward, rewind, increase volume, decrease volume, get the current song name, get the current volume then returns the current volume, and also sets the volume to 5 and current song to 2. It also has a string array to store the songs (array of size 15 and can hold up to 15 songs), int to keep track of the volume, and int to keep track of the current song.......Here's what I have so far!
#include <iostream>
#include <string>
using namespace std;
class cd
{
public:
cd player(volume = 5, song = 2 );
string song [15];
int forward;
int rewind;
string getSong();
int getVolume();
private:
string song;
int volume;
};
ANY SUGGESTIONS????
I would use a std::vector<std::string> instead of the song array.
That way you can keep easily track of how many songs you actually use, and you don't limit yourself to a maximum of 15 songs.
If string song; is a field to determine what is the current song, then i suggest to change it to an index into the song. This makes it possible to get the next song easily, while you can retrieve the current song name as well.
1) You can't have song as both a private string and a public string[15].
2) You can't have the word player in your constructor. The constructor is simply the name of the class. e.g. cd (volume = 5, song = 2 );
Please learn to use code tags (the <> formatting button) when posting code.
It makes is easier to refer to specific lines of code.