C++ Update Object attributes using set function

This question already has an answer here:

  • What's the difference between passing by reference vs. passing by value? 18 answers

  • You need to pass booklist by reference:

    void UpdateOnIsbn(vector <CBooks>& booklist)
    

    Otherwise the vector is copied and only this copy is modified.


    You are passing a copy of booklist so you are modifying the copy not the original object.

    Try passing a reference to the function void UpdateOnIsbn(vector <CBooks>& booklist)

    链接地址: http://www.djcxy.com/p/20608.html

    上一篇: 何时将引用用作C ++中的参数

    下一篇: 使用set函数的C ++更新对象属性