We have been assigned to create an iTunes library. Everything compiles in my other .h file but my main is not happy with my object declaration. It keeps stating "primary expression before '{'". Here is my main code:
#include<iostream>
#include<string>
#include<fstream>
#include"myTunes.h"
int main(){
int choice;
string file;
Song everything[100];
myTunes m1(100, everything[100]);
cout<<"Enter in library to import: "<<endl; //get file name
cin>>file;
file+=".txt";
m1.read(file);
m1.print();
//menu options
cout<<"Sort library by: "<<endl;
cout<<"1) Song Name"<<endl;
cout<<"2) Artist Name"<<endl;
cout<<"3) Album Name"<<endl;
cout<<"4) Track Time"<<endl;
cout<<"5) Year of Release"<<endl;
cout<<"Search library for: "<<endl;
cout<<"6) A song name"<<endl;
cout<<"7) An artist name"<<endl;
cout<<"8) An album name"<<endl;
cout<<"9) Quit"<<endl;
cin>>choice;
if ((choice > 5) && (choice != 9)){
m1.search(choice);
}
else if ((choice < 5) && (choice !=9)) {
m1.sort(choice);
}
else if (choice == 9){
cout<<"Goodbye"<<endl;
}
return 0;
}
and this is my .h file constructor:
class myTunes{
public:
//constructor
myTunes(int n, Song everything[]){
setNumberOfSongs(n);
setSongs(everything);
}
If you edit your post, highlight your code and click the <> button under the Format: on the right side of the post, it'll format your code for the forum and make it easier to read :)
Is that all there is in the h file? You're missing a closing }; at the end of the class. Where is Song defined? And you're missing definitions of functions you've prototyped in what you've posted.