欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

6-4 猫和老鼠有多重

最编程 2024-05-04 07:19:03
...
class Mouse;
class Cat
{
    int weight;
    public :
    Cat(int m)
    {
        weight=m;
    }
    friend int totalWeight(Cat t1,Mouse j1);
};
class Mouse
{
    int weight;
    public:
    Mouse(int m)
    {
        weight=m;
    }
    friend int totalWeight(Cat t1,Mouse j1);
};
int totalWeight(Cat t1,Mouse j1)
{
    return t1.weight+j1.weight;
}