I am having the below compile errors 1 Build started Projec
I am having the below compile errors.
***********************************************************************************
1>------ Build started: Project: playlist, Configuration: Debug Win32 ------
1> Playlist.cpp
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(74): error C3867: \'std::list<Playlist,std::allocator<_Ty>>::size\': non-standard syntax; use \'&\' to create a pointer to member
1> with
1> [
1> _Ty=Playlist
1> ]
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(74): error C2296: \'>\': illegal, left operand has type \'unsigned int (__thiscall std::list<Playlist,std::allocator<_Ty>>::* )(void) noexcept const\'
1> with
1> [
1> _Ty=Playlist
1> ]
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(74): error C2297: \'>\': illegal, right operand has type \'unsigned int (__thiscall std::list<Playlist,std::allocator<_Ty>>::* )(void) noexcept const\'
1> with
1> [
1> _Ty=Playlist
1> ]
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(76): error C2065: \'it\': undeclared identifier
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(78): error C2065: \'it\': undeclared identifier
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(78): error C2227: left of \'->GetID\' must point to class/struct/union/generic type
1> c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(78): note: type is \'unknown-type\'
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(80): error C2065: \'it\': undeclared identifier
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(80): error C2227: left of \'->GetSongName\' must point to class/struct/union/generic type
1> c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(80): note: type is \'unknown-type\'
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(81): error C2065: \'it\': undeclared identifier
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(144): error C3867: \'std::list<Playlist,std::allocator<_Ty>>::size\': non-standard syntax; use \'&\' to create a pointer to member
1> with
1> [
1> _Ty=Playlist
1> ]
1>c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(144): error C2446: \'<=\': no conversion from \'unsigned int (__thiscall std::list<Playlist,std::allocator<_Ty>>::* )(void) noexcept const\' to \'int\'
1> with
1> [
1> _Ty=Playlist
1> ]
1> c:\\users\ rg\\documents\\visual studio 2015\\projects\\playlist\\playlist\\playlist.cpp(144): note: There is no context in which this conversion is possible
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
****************************************************************
I have three files:
Main.cpp
#include <iostream>
#include \"Playlist.h\"
using namespace std;
int main()
{
int choice;
string uqid = \"\";
string songnam = \"\";
string artname;
int len;
PlaylistNode PlaylistNode;
do
{
cout << \"MENU\" << endl;
cout << \"a - Add song: \" << endl;
cout << \"d - Remove song: \" << endl;
cout << \"c - Change position of song \" << endl;
cout << \"s - Output songs by specific artist: \" << endl;
cout << \"t - Output total time of playlist (in seconds): \" << endl;
cout << \"o - Output full playlist \" << endl;
cout << \"q - QUIT PROGRAM \" << endl;
cout << \"Please enter your selection.\" << endl;
cin >> choice;
switch (choice)
{
case \'a\':
{
cout << \"ADD SONG\" << endl;
cout << \"Enter song\'s unique ID:\" << endl;
cin >> uqid;
cout << \"Enter song\'s name:\" << endl;
cin >> songnam;
cout << \"Enter artist\'s name:\" << endl;
cin >> artname;
cout << \"Enter Song len\" << endl;
cin >> len;
Playlist playlistobj(uqid, songnam, artname, len);
PlaylistNode.Addsong(playlistobj);
break; //Add record
}
case \'d\':
{
cout << \"REMOVE SONG\" << endl;
cout << \"Enter song\'s unique ID:\" << endl;
cin >> uqid;
PlaylistNode.Removesong(uqid);
}
break; //Display record
case \'c\':
{
int Creentpos = 0;
int newpos = 0;
cout << \"Enter song\'s current position:\" << endl;
cin >> Creentpos;
cout << \"Enter new position for song:\" << endl;
cin >> newpos;
PlaylistNode.Changeposition(Creentpos, newpos);
}
case \'s\':
cout << \"Enter artist\'s name:\" << endl;
cin >> artname;
PlaylistNode.PrintSongByartist(artname);
break; //EDit record
case \'t\':
PlaylistNode.PrintSongtotalLen();
break; //EDit record
case \'o\':
PlaylistNode.PrintFullPlayList();
break; //EDit record
case \'q\':
cout << \"QUIT PROGTRAM--\" << endl;
break;
default: cout << \"Invalid Selection\" << endl;
}
} while
(choice == \'q\');
system(\"PAUSE\");
return 0;
}
Playlist.cpp
#include \"Playlist.h\"
Playlist::Playlist(string auniqueId, string asongName, string aArtistName, int aSongLength)
{
uniqueID = auniqueId;
songName = asongName;
artistName = aArtistName;
songLength = aSongLength;
}
string Playlist::GetArtistName()
{
return artistName;
}
string Playlist::GetID()
{
return uniqueID;
}
string Playlist::GetSongName()
{
return songName;
}
int Playlist::GetSongLength()
{
return songLength;
}
void Playlist::SetNext()
{
}
string Playlist::GetNext()
{
return \"\";
}
void Playlist::InsertAfter() {
}
void Playlist::PrintPlaylistNode()
{
cout << \"Unique ID:\" << uniqueID << endl;
cout << \"Song Name:\" << songName << endl;
cout << \"Artist Name:\" << artistName << endl;
cout << \"Song Length (in seconds):\" << songLength << endl;
}
////
void PlaylistNode::Addsong(Playlist aPlaylist)
{
library.push_back(aPlaylist);
}
void PlaylistNode::Removesong(string aUnwiid)
{
if (library.size > 0)
{
for (it = library.begin(); it != library.end(); ++it)
{
if (it->GetID() == aUnwiid)
{
cout << it->GetSongName() << endl;
library.remove(*it);
break;
}
}
}
}
Playlist PlaylistNode::get(list<Playlist> _list, int _i) {
list<Playlist>::iterator it = _list.begin();
for (int i = 0; i<_i; i++) {
++it;
}
return *it;
}
std::list<Playlist>::iterator it;
void PlaylistNode::PrintFullPlayList()
{
for (it = library.begin(); it != library.end(); ++it)
{
PrintPlaylist(*it);
}
}
void PlaylistNode::PrintSongByartist(string aartiename)
{
for (it = library.begin(); it != library.end(); ++it)
{
if (it->GetArtistName() == aartiename)
PrintPlaylist(*it);
}
}
void PlaylistNode::PrintSongtotalLen()
{
int TotalSonglengst = 0;
for (it = library.begin(); it != library.end(); ++it)
{
TotalSonglengst += it->GetSongLength();
}
cout << \"Total songs Length (in seconds):\" << TotalSonglengst << endl;
}
void PlaylistNode::PrintPlaylist(Playlist aPlayList)
{
cout << \"Unique ID:\" << aPlayList.GetID() << endl;
cout << \"Song Name:\" << aPlayList.GetSongName() << endl;
cout << \"Artist Name:\" << aPlayList.GetArtistName() << endl;
cout << \"Song Length (in seconds):\" << aPlayList.GetSongLength() << endl;
}
void PlaylistNode::Changeposition(int oldPostion, int newPostinon)
{
if (!library.empty())
{
if (newPostinon <= library.size)
{
Playlist oldPlalist = get(library, oldPostion);
Playlist New_Playlist = get(library, newPostinon);
Playlist pldpay(oldPlalist.GetID(), oldPlalist.GetSongName(), oldPlalist.GetArtistName(), oldPlalist.GetSongLength());
/*library.insert(pldpay,newPostinon);
library.insert(New_Playlist, oldPostion);*/
}
else
{
cout << \"The Postion is Not in the Range of LIB\" << endl;
}
}
}
Playlist.h
#pragma once
#include <iostream>
#include <string>
#include <string>
#include <vector>
#include <list>
using namespace std;
class Playlist
{
private:
string uniqueID;
string songName;
string artistName;
int songLength;
public:
Playlist() { uniqueID = \"\", songName = \"\", artistName = \"\", songLength = 0; };
Playlist(string auniqueId, string asongName, string aArtistName, int aSongLength);
void InsertAfter();
void SetNext();
string GetID();
string GetSongName();
string GetArtistName();
int GetSongLength();
string GetNext();
void PrintPlaylistNode();
};
//#pragma once
//#include \"Playlist.h\"
//#include <list>
class PlaylistNode
{
private:
std::list<Playlist> library;
Playlist get(list<Playlist> _list, int _i);
void PrintPlaylist(Playlist aPlayList);
public:
void Addsong(Playlist aPlayslist);
void Removesong(string aUnwiid);
void Changeposition(int oldPostion, int anewPostion);
void PrintSongByartist(string aAstist);
void PrintSongtotalLen();
void PrintFullPlayList();
};
Solution
Here is the modified code for you:
Main.cpp
#include <iostream>
#include \"Playlist.cpp\"
using namespace std;
int main()
{
int choice;
string uqid = \"\";
string songnam = \"\";
string artname;
int len;
PlaylistNode PlaylistNode;
do
{
cout << \"MENU\" << endl;
cout << \"a - Add song: \" << endl;
cout << \"d - Remove song: \" << endl;
cout << \"c - Change position of song \" << endl;
cout << \"s - Output songs by specific artist: \" << endl;
cout << \"t - Output total time of playlist (in seconds): \" << endl;
cout << \"o - Output full playlist \" << endl;
cout << \"q - QUIT PROGRAM \" << endl;
cout << \"Please enter your selection.\" << endl;
cin >> choice;
switch (choice)
{
case \'a\':
{
cout << \"ADD SONG\" << endl;
cout << \"Enter song\'s unique ID:\" << endl;
cin >> uqid;
cout << \"Enter song\'s name:\" << endl;
cin >> songnam;
cout << \"Enter artist\'s name:\" << endl;
cin >> artname;
cout << \"Enter Song len\" << endl;
cin >> len;
Playlist playlistobj(uqid, songnam, artname, len);
PlaylistNode.Addsong(playlistobj);
break; //Add record
}
case \'d\':
{
cout << \"REMOVE SONG\" << endl;
cout << \"Enter song\'s unique ID:\" << endl;
cin >> uqid;
PlaylistNode.Removesong(uqid);
}
break; //Display record
case \'c\':
{
int Creentpos = 0;
int newpos = 0;
cout << \"Enter song\'s current position:\" << endl;
cin >> Creentpos;
cout << \"Enter new position for song:\" << endl;
cin >> newpos;
PlaylistNode.Changeposition(Creentpos, newpos);
}
case \'s\':
cout << \"Enter artist\'s name:\" << endl;
cin >> artname;
PlaylistNode.PrintSongByartist(artname);
break; //EDit record
case \'t\':
PlaylistNode.PrintSongtotalLen();
break; //EDit record
case \'o\':
PlaylistNode.PrintFullPlayList();
break; //EDit record
case \'q\':
cout << \"QUIT PROGTRAM--\" << endl;
break;
default: cout << \"Invalid Selection\" << endl;
}
} while
(choice == \'q\');
system(\"PAUSE\");
return 0;
}
Playlist.cpp:
#include \"Playlist.h\"
Playlist::Playlist(string auniqueId, string asongName, string aArtistName, int aSongLength)
{
uniqueID = auniqueId;
songName = asongName;
artistName = aArtistName;
songLength = aSongLength;
}
string Playlist::GetArtistName()
{
return artistName;
}
string Playlist::GetID()
{
return uniqueID;
}
string Playlist::GetSongName()
{
return songName;
}
int Playlist::GetSongLength()
{
return songLength;
}
void Playlist::SetNext()
{
}
string Playlist::GetNext()
{
return \"\";
}
void Playlist::InsertAfter() {
}
void Playlist::PrintPlaylistNode()
{
cout << \"Unique ID:\" << uniqueID << endl;
cout << \"Song Name:\" << songName << endl;
cout << \"Artist Name:\" << artistName << endl;
cout << \"Song Length (in seconds):\" << songLength << endl;
}
////
void PlaylistNode::Addsong(Playlist aPlaylist)
{
library.push_back(aPlaylist);
}
void PlaylistNode::Removesong(string aUnwiid)
{
if (library.size() > 0)
{
for (list<Playlist>::iterator it = library.begin(); it != library.end(); ++it)
{
if (it->GetID() == aUnwiid)
{
cout << it->GetSongName() << endl;
library.remove(*it);
break;
}
}
}
}
Playlist PlaylistNode::get(list<Playlist> _list, int _i) {
list<Playlist>::iterator it = _list.begin();
for (int i = 0; i<_i; i++) {
++it;
}
return *it;
}
std::list<Playlist>::iterator it;
void PlaylistNode::PrintFullPlayList()
{
for (it = library.begin(); it != library.end(); ++it)
{
PrintPlaylist(*it);
}
}
void PlaylistNode::PrintSongByartist(string aartiename)
{
for (it = library.begin(); it != library.end(); ++it)
{
if (it->GetArtistName() == aartiename)
PrintPlaylist(*it);
}
}
void PlaylistNode::PrintSongtotalLen()
{
int TotalSonglengst = 0;
for (it = library.begin(); it != library.end(); ++it)
{
TotalSonglengst += it->GetSongLength();
}
cout << \"Total songs Length (in seconds):\" << TotalSonglengst << endl;
}
void PlaylistNode::PrintPlaylist(Playlist aPlayList)
{
cout << \"Unique ID:\" << aPlayList.GetID() << endl;
cout << \"Song Name:\" << aPlayList.GetSongName() << endl;
cout << \"Artist Name:\" << aPlayList.GetArtistName() << endl;
cout << \"Song Length (in seconds):\" << aPlayList.GetSongLength() << endl;
}
void PlaylistNode::Changeposition(int oldPostion, int newPostinon)
{
if (!library.empty())
{
if (newPostinon <= library.size())
{
Playlist oldPlalist = get(library, oldPostion);
Playlist New_Playlist = get(library, newPostinon);
Playlist pldpay(oldPlalist.GetID(), oldPlalist.GetSongName(), oldPlalist.GetArtistName(), oldPlalist.GetSongLength());
/*library.insert(pldpay,newPostinon);
library.insert(New_Playlist, oldPostion);*/
}
else
{
cout << \"The Postion is Not in the Range of LIB\" << endl;
}
}
}
Playlist.h:
#pragma once
#include <iostream>
#include <string>
#include <string>
#include <vector>
#include <list>
using namespace std;
class Playlist
{
private:
string uniqueID;
string songName;
string artistName;
int songLength;
public:
Playlist() { uniqueID = \"\", songName = \"\", artistName = \"\", songLength = 0; };
Playlist(string auniqueId, string asongName, string aArtistName, int aSongLength);
void InsertAfter();
void SetNext();
string GetID();
string GetSongName();
string GetArtistName();
int GetSongLength();
string GetNext();
void PrintPlaylistNode();
};
//#pragma once
//#include \"Playlist.h\"
//#include <list>
class PlaylistNode
{
private:
std::list<Playlist> library;
Playlist get(list<Playlist> _list, int _i);
void PrintPlaylist(Playlist aPlayList);
public:
void Addsong(Playlist aPlayslist);
void Removesong(string aUnwiid);
void Changeposition(int oldPostion, int anewPostion);
void PrintSongByartist(string aAstist);
void PrintSongtotalLen();
void PrintFullPlayList();
};












