我想问问怎么更新数据啊


#include 
using namespace std;

class Book
{//修改及补充其它设计代码


private:
    const long BID;                    //图书编号
    double price=0;                    //图书价格
    static double total;               //图书总金额
public:
    static int count;               //图书总数量
    Book(long m_BID, double m_price) :BID(m_BID), price(m_price)//构造函数
    {
        cout << "ID:" << BID << "        " << "price:" << price << endl;
        ++count;
        total += price;
    }
    Book(const Book&a) :BID(a.BID),price(a.price)//拷贝函数
    {
        cout << "ID:" << a.BID <<"0"<< "        " << "price:" << a.price << endl;
        ++count;
        total += price;
    }
    ~Book() { ; }
    void setX(long m_BID) { m_BID = BID; }
    long getX() { return BID; }
    void setY(double m_price) { m_price = price; }
    double getY() { return price; }
    static int howmany() { return count; }//返回当前有多少个Book对象
    static double howmuch() { return total; }


};
int Book::count = 0;
double Book::total = 0;
int main()
{
    Book books[] = { Book(100001L, 40.3), Book(100002L, 35.0) };
    Book book1(books[0]);
    //补充代码输出当前图书馆藏书总数及总金额
    cout << "图书总数:" << Book::howmany() << "      " << endl << "图书总金额:" << Book::howmuch() << endl;
    return 0;
}
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/668250358086199.png "#left")

img

构造函数你已经写了啊

~Book() { 
        --count;
        total -= price;
 }