关于静态成员的生成和销毁以及布尔函数真假判断条件的疑问

img

绿色的注释是我尝试失败的
#include<iostream>
using namespace std;
class Boat;
class Cat;
class Cat
{
    friend class Boat;
    friend double getTotalWeight(Cat& aCat, Boat& aBoat);
private:
    double weight;
    int numofcats;
    bool IsConstruted;
public:
    void getNumOfCats(bool IsConstruted);
    Cat(double j) { weight = j; }
};
class Boat
{
    friend Cat;
    friend double getTotalWeight(Cat& aCat, Boat& aBoat);
private:
    double weight;
public:
    Boat(double j) { weight = j; }
};

//void Cat::getNumOfCats(bool IsConstruted)
//{
//    int l = numofcats;
//    static int numofcats = 0;
//    if (IsConstruted == true)
//    {
//        numofcats++;
//        cout << "Cat Object is constructing, the constructed Number is " << numofcats << ", and the lived Number is 1" << endl;
//        cout << "Cat Object is deconstructing, and the lived Number is 0" << endl;
//    }
//    if(IsConstruted == false)
//    {
//        cout << "Cat Object is deconstructing, and the lived Number is 0" << endl;
//    }
//}


double getTotalWeight(Cat& aCat, Boat& aBoat)
{
    return  aCat.weight + aBoat.weight;
}

int main()
{
    int n;
    int i = 0;
    double w0, w1;
    cin >> n;
    cin >> w0;
    cin >> w1;
    for(;n >= 0;n--)
    {
        i++;
        cout << "Cat Object is constructing, the constructed Number is " << i << ", and the lived Number is 1" << endl;
        if (n > 0)
        {
            cout << "Cat Object is deconstructing, and the lived Number is 0" << endl;
        }
    }
    Cat c(w0);
    Boat b(w1);
    cout << getTotalWeight(c, b) << endl;
    cout << "Cat Object is deconstructing, and the lived Number is 0" << endl;
    return 0;
}

我不明白_getNumOfCats(bool IsConstruted)的真假是根据什么条件判断的_

静态数据成员numOfCats,记录已经创建的Cat对象的个体数目,静态数据成员numOfCatsGo,记录已经销毁的Cat对象的个体数目
怎么使用
怎么样利用
静态成员函数getNumOfCats(bool IsConstruted),当IsConstruted为true时读取numOfCats,当IsConstruted为false时读取numOfCatsGo
去解题呢

代码功能归根结底不是别人帮自己看或讲解或注释出来的;而是被自己静下心来花足够长的时间和精力亲自动手单步或设断点或对执行到某步获得的中间结果显示或写到日志文件中一步一步分析出来的。
提醒:再牛×的老师也无法代替学生自己领悟和上厕所!
单步调试和设断点调试(VS IDE中编译连接通过以后,按F10或F11键单步执行,按Shift+F11退出当前函数;在某行按F9设断点后按F5执行停在该断点处。)是程序员必须掌握的技能之一。