Thread: Need help....AGAIN

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    66

    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! ^^
    An Unofficial Cristiano Ronaldo Website : Ronaldo 7

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    > 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

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >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

Popular pages Recent additions subscribe to a feed