首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

请教下面的静态联编例子为什么运行有异常,请各位告诉不吝赐教,先多谢咯

2012-04-16 
请问下面的静态联编例子为什么运行有错误,请各位告诉不吝赐教,先谢谢咯//静态联编例子#includeiostream.h

请问下面的静态联编例子为什么运行有错误,请各位告诉不吝赐教,先谢谢咯
//静态联编例子
#include<iostream.h>
class Point
{
Point(double i,double j){x=i;y=j;}
double Area() const {return 0.0;}
private:
double x,y;
};
class Rectangle:public Point
{
public:Rectangle(double i,double j,double k,double I);
double Area() const {return w*h;};
private:
double w,h;
};
Rectangle::Rectangle(double i,double j,double k,double I):Point(i,j)
{w=k;h=I;}
void fun(Point &s)
{
cout<<"Area="<<s.Area()<<endl;
}
void main()
{
Rectangle rec(3.0,5.2,15.0,25.0);
fun(rec);
}

[解决办法]
楼上的不对,你只需要在Point里面的构造函数前加Public就行了,不加的话默认是Private

热点排行