mardi 27 octobre 2015

Is a copy made when passing by 'implied'(?) reference in C++

If I have a function that takes a reference to a map:

pair<int,int> myFunc(map<int,char> &myVar){...}

I can pass it a map without needing the '&'.

myFunc(someMapitoa);

Is there any difference? Is a copy made and then thrown away? Should I use the '&' anyway?

Aucun commentaire:

Enregistrer un commentaire