有一道关于运算符重载友元函数的问题,望各位大哥赐教!
//运算符重载友元函数各位大哥,帮我看看这个程序有啥子问题,搞了一上午硬是没搞得懂错在哪里,我觉得没错呀,如果看出错误,望指出错误,谢谢啦。
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
class Point
{
public:
Point(double i,double j)
{
x=i,y=j;
}
double Area()const
{
return 0.0;
}
private:
double x;
double y;
};
class Rectangle:public Point
{
public:
Rectangle(double i,double j,double k,double l);
double Area()const
{
return w*h;
}
private:
double w,h;
};
Rectangle::Rectangle(double i,double j,double k,double l):Point(i,j)
{
w=k;
h=l;
}
void fun(Point &s)
{
printf("s.Area=%5.1f\n",s.Area());
}
int _tmain(int argc, _TCHAR* argv[])
{
Rectangle abc(3.0,5.2,8.0,9.0);
fun(abc);
system("pause");
return 0;
}