c++ - Passing containers by value or by reference -


i aware of differences between pass value, reference or pointer in general case. however, question special case container simple structure.

assuming case:

class image{     image()=default;     image(image const&)=default;     ~image()=default;      int w;     int h;     uchar* data; } 

when passing object of class copied 2 integers , pointer not whole data. in case there purpose passing reference ? or there purpose not passing reference?

the thing triggered question have read iterators in c++ designed light , passed value. so, think concept may applied classes represent container actual data no data.

imho, best guidelines on how pass arguments can found in herb sutters excellent talk back basics! essentials of modern c++ style. in particular case, passing value best option, struct cheap copy.

cpp parameter passing overview.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -