brisk172 brisk172 - 4 months ago 42
C++ Question

C++ Function Coding

I just started learning functions. I'm trying to write this code with using a function to have a user input the names. I can't figure out what the argument should be. I thought I could put in getName( passing an array into it, but I'm doing it wrong. What should the correct parameter be?

void getName(Horse &); //function prototype
struct Horse
string name;
array<Horse, horseCount> Horses;
for (Horse &i : Horses)
void getName(Horse &Nag)
cout << "Enter a horse's name: ";


You are passing a std::string to getName() when it actually expects Horse&.

You must call it as getname(i) to actually pass the Horse object.