为什么无论sumnum的值是多少,程序一直输出50
#include<iostream>using namespace std;
class Book
{public:
Book(int w);
static int sumnum;
static void display();
private:
int num;
};
Book::Book(int w)
{
num=w;
sumnum=120;
sumnum-=w;
}
void Book::display()
{ cout<<Book::sumnum<<endl;}
int Book::sumnum=10000;
int main()
{
Book b1(20);
Book b2(70);
b1.display();
b2.display();
return 0;
}