Firstly, a lot depends on whether you pass objects by reference or by value.
In C # and Java, you always pass objects by reference, but in C ++ you can pass a copy of the object on the stack (i.e. pass-by-value). This includes making a physical copy of the object in memory, which implies a couple of calls to the constructor / destructor (at least).
Passing int can be done either by value or by reference. If you pass by value, you copy the int type (let it be 32 bits ) 32 bits stack. If you pass a pointer, you copy the address (again, say 32 bits ) 32 bits stack. In fact, there is no difference in the use of the stack. In the case of passing by reference, the calling function will have to dereference the pointer in order to access the value of the int parameter, so there will be some additional code (and, possibly, performance degradation).
Passing an object (or structure) by value compared to a link is more interesting because they can have very different memory traces (depending on the size of the class / structure).
source share