void ReadMembers(AptType& apt)
{
// read values from keyborad
// into the members of struct parameter apt. The order in
// which the data is read is the same as that of the items
// in the struct.
string landLord;
string address;
int bedRooms;
float price;
cout << "Please enter the landlord: " << endl;
cin >> apt.landLord;
cout << "Please enter the address: " << endl;
cin >> apt.address;
cout << "Please enter the number of the bedrooms: " << endl;
cin >> apt.bedRooms;
cout << "Please enter the price: " << endl;
cin >> apt.price;
}
int main()
{
AptType apartment;
// Read values into the members of apartment variable.
ReadMembers(apartment);
// Print out the values of members.
cout << "The landlord is " << apartment.landLord << endl;
cout << "The address is " << apartment.address << endl;
cout << "The number of bedrooms is " << apartment.bedRooms
<< endl;
cout << "The price is " << apartment.price << endl;
return 0;
}
[/code:1]
编译可以成功, 也可以运行, 但它总给我两个Warning, 就是在void ReadMembers()里的price和bedRooms说是"Unreferenced local variable", 为什么????