Hello,
I have one easy question:
Qt Code:
  1. class A {
  2. private:
  3. int _number;
  4. vector<A> Vector;
  5. public:
  6. A(int n) { _number = n; }
  7. A() {}
  8. void addCopy(A a) { Vector.push_back(a); }
  9. void addReference(A* a) {
  10. Vector.push_back(*a);
  11. }
  12. };
  13.  
  14. int main (int argc, char** argv) {
  15. A aa;
  16. A bb(99);
  17. aa.addCopy(bb);
  18. aa.addReference(&bb);
  19. return EXIT_SUCCESS;
  20. }
To copy to clipboard, switch view to plain text mode 

In this case, A keep a vector and when push_back() is called, it makes a copy; Then regarding addCopy: 1. pass bb to add (and it makes one copy of bb); 2. push a into Vector (and make one other copy). With referenceCopy instead I can avoid overhead of passing bb to the add() (and if bb it's large it can enhance the performance). With this above I wonder: why should I pass an objects (e.g. A) as value? I'm thinking that It's better pass an object always by reference (IF I DON'T CHANGE IT INSIDE THE FUNCTION, like I do in this case)
Is this above right?

thanks