By writing the getter() and setter() methods without using them, you extend the runtime of the program. Also, the -Wunused-variable marker is automatically used by your compiler. I edited your code for you, there is no problem.
#include <bits/stdc++.h>
typedef std::string s;
class Song {
public:
s n;
int d;
//Constructor
Song(int d, s n) {
this->d = d;
this->n = n;
}
void print() const{
std::cout << d << " - " << n << std::endl;
}
};
int main(int argc, char* argv[]) {
std::vector<Song> playlist;
s name;
int duration;
while(true) {
std::cin>>duration;
if(duration<0) break;
else {
std::cin>>name;
Song newSong(duration,name);
playlist.push_back(newSong);
}
}
for(int i=0;i<playlist.size();i++) {
Song p = playlist.at(i);
p.print();
}
return 0;
}