今天学习了c++的静态属性,下面有一个简单的程序,希望对于和我一样自学的朋友练习有帮助。
#include <iostream>
#include <cstdio>
using namespace std;
class CRectangle
{
private:
int w,h;
static int nTotalArea;
static int nTotalNumber;
public:
CRectangle(int w_,int h_);
~CRectangle();
static void PrintTotal();
};
CRectangle::CRectangle(int w_,int h_)
{