I am aware of the differences between pass by value, reference or pointer in the general case. However, my question is about special case about a container with simple structure.
Assuming this case:
class image{
image()=default;
image(image const&)=default;
~image()=default;
int w;
int h;
uchar* data;
}
When passing an object of this class what copied are just two integers and pointer not the whole data. In this case is there purpose to passing it by reference ? Or is there a purpose to not passing it by reference?
The thing that triggered this question is that I have read that iterators
in C++ were designed to be light and to be passed by value. So, I think that this concept may be applied to classes that represent a container to actual data no a data.
Aucun commentaire:
Enregistrer un commentaire