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;
}
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;
}
上一篇: Java 案例 - 猫和狗(界面版)
下一篇: 看看动漫中猫的原型,你最喜欢哪一个?