I can't figure out how to fix this code.
void getInfo(Author a[], int size)
{
for(int x = 0; x < size; x++)
{
cout << "Enter the author's name: ";
getline(cin, a[x].name);
if(a[x].name == "NONE")
break; //Breaks the loop if the author has no further books
else
for(int y = 0; y < size; y++)
{
cout << "Enter title " << y+1 << " :";
getline(cin, a[x].book[y].title);
if(a[x].book[y].title == "NONE")
break;
else
cout << "Enter price " << y+1 << " : $";
cin >> a[x].book[y].price;
}
cout << endl;
}
}
This is how it is compiling:
Get user's input:
Enter the author's name: John Smith
Enter title 1: How to Tie a Shoe
Enter price 1: 20
Enter title 2: Enter price 2:
Could someone please help me understand how to fix this loop. When I try a getline(cin, a[x].book[y].price);
,visual studio tells me that it is overloaded.