So I have a class called songs. I have about 4 songs that i would like to randomly pick one of the 4 songs. I was working on a small program to try and accomplish this but no luck.
Anyone have some insight they may be able to offer.
#include <vector>
#include <cstdlib>
#include <time>
usingnamespace std;
vector<song*> Songs; //vector storage is good for random access
int numSongs = 0;
int randomSongIndex = 0;
//add songs, increment the number of songs
srand(time());
randomSongIndex = rand() % numSongs + 1;
Songs[randomSongIndex]->Play();