标题:(出错)友元函数的调用
取消只看楼主
hxjtiger
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2007-10-9
 问题点数:0 回复次数:0 
(出错)友元函数的调用
#include<iostream>
using namespace std;
class car;
class boat
{
public:
 
 boat(int nw=100)
 {
  w=nw;
 }
 friend int car::total(boat &p1,car &p2);
private:
 int w;
};
class car
{
public:
 
 car(int nw=50)
 {
  w=nw;
 }
    int total(boat &p1,car &p2)
 {
  return p1.w+p2.y ;
 }
private:
 int y;
};
void main()
{
 boat boat1(1000);
 car car1(2000);
 cout<<"totalweight is"<<car1.total(boat1,car1)<<endl;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
你们帮我看看,怎么是一个类中的函数成为另一个类的友元函数调用类中的私有数据????
搜索更多相关主题的帖子: car boat int 函数 
2007-11-28 20:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-189078-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.342065 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved