c++ - In " void City::setList(List<City*> *l){list = l;}" , what does List<City*> *l means? -


i doing assignment , not @ understanding pointers. please me understand argument need pass function.

void city::setlist(list<city*> *l){list = l;} 

without seeing definition list (and because google case-insensitive), can't give exact answer, you'll want construct this:

list<city*> mylist; 

then (assuming list works java's list):

city c; //or constructor, or whatever mylist.add(&c); 

to call method:

// `d` other city d.setlist(&mylist); 

there's 1 major caveat, though: unless created c new (which, given syntax example used here, didn't), pointers going dangling c goes out of scope. you'll want make sure aren't doing that. , if create new, have sure delete later.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -