//A is less than B
void Add(vector<song> &l)
{
song ns;
cout<<"What is the name of the song?"<<endl;
getline(cin,ns.t);
cout<<"What is the artist name?"<<endl;
getline(cin,ns.a);
cout<<"What is the length of the song?"<<endl;
cin>>ns.l;
l.push_back(ns);
}
void Title(song.t)
{
string tt;
if(t>tt)
{
}
}
void Playlist()
{
}
int main()
{
vector<song>l;
int x;
while(x!=6)
{
cout<<"Hello welcome to VSPod."<<endl;
cout<<"(1) Add a song."<<endl;
cout<<"(2) Sort by title."<<endl;
cout<<"(3) Sort by artist."<<endl;
cout<<"(4) Sort by length."<<endl;
cout<<"(5) Print your playlist."<<endl;
cout<<"(6) EXIT."<<endl;
cout<<"Pick one:";
cin>>x;
cin.clear();
cin.sync();
if(x==1)
{
Add(l);
}
if(x==2)
{
Title();
}
if(x==3)
{
}
if(x==4)
{
}
if(x==5)
{
}
}
}
this is my code and my problem is im trying to sort the title but i cant acess the title file
my problem wasn't how to compare the two songs but what i called the second song when i compared because i dont understand how to acess another song title because in the example from your link they have to variables that they compare to
t stands for the title and ns is where the song the user enters is stored and each time the user enters a song it gets stored in l...do you know who to access the different ns in the vector l?
Okay. That makes sense. I thought that since it wasn't a number being stored I couldn't just put o in the brackets. do you think that this sorting of the title is correct: