These are my Structs:
struct Artist
{
string Name;
string CountryOfOrigin;
};
struct Time
{
int Minutes;
int Seconds;
};
struct Song
{
string Title;
Artist ArtistDetails;
Time LengthOfSong;
};
And my Function:
void LoadSongDataFromFile(Song s[])
{
string inputFile, title, name, country;
int minutes, seconds;
cout << "Please enter the input file name: ";
cin >> inputFile;
ifstream input;
input.open(inputFile);
int count = 0;
while (input >> title)
{
s[count].Title >> title;
s[count].ArtistDetails.Name >> name;
s[count].ArtistDetails.CountryOfOrigin >> country;
s[count].LengthOfSong.Minutes >> minutes;
s[count].LengthOfSong.Seconds >> seconds;
count++;
}
}
I'm getting an error in these three lines:
s[count].Title >> title;
s[count].ArtistDetails.Name >> name;
s[count].ArtistDetails.CountryOfOrigin >> country;
Saying no operator >> matches these opperands. Opperand types are: std::string >> std::string
Also the data I'm trying to put into the struct array comes from a text file which contains this information:
Perfect
Ed Sheeran with Beyonce
England
4
23
The text file name is songdata.txt if that matters. Any help is greatly appreciated!