I am in the process of learning c++. So i know a method by which you send something to function and then work as if it was call by value but actually it is call by reference. For example
void myFUNC(string& x)
Now, I have a dynamically created array of objects. I want to pass the array to function like a method above. Here's the code snippets
City *p = new City[number]; // pointer to dynamic array of class objects
//function prototype
void list_cities(int number, City p[]){
for(int i=0; i<number; i++){
cout<<p[i].get_name()<<endl;
}
}
list_cities(number, p);std::vector.list_cities(number, p)