-
Need help....AGAIN
I think it's a simple syntax error, but I can't seem to fix it.
Code:
#include <iostream>
using namespace std;
class Town
{
public:
Town(string Name): name(Name) {} //constructor
protected:
string name;
};
void cho_destin(Town& towns[], int& location) //function that causes ERROR
{}
Town towns[6] = {Town("Bronx"), Town("Ghetto"), Town("Central Park"), Town("Manhattan"),
Town("Coney Island"), Town("Brooklyn")};
int location = -1; //location ( -1 is starting point)
int main()
{
cho_destin(towns[6], location); //prompts user to choose destination
system("PAUSE");
return 0;
}
Thx for the help! ^^
-
> cho_destin(towns[6], location); //prompts user to choose destination
To pass an array to the function use:
cho_destin(towns, location); //prompts user to choose destination
-
>void cho_destin(Town& towns[], int& location) //function that causes ERROR
And you don't need the & to pass the array by reference, arrays are passed by reference by default:
void cho_destin(Town towns[], int& location) //function that causes ERROR