标题:[转载][求助]
取消只看楼主
lanshulin
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-12-7
 问题点数:0 回复次数:0 
[转载][求助]

#include "stdafx.h"
#include "iostream.h"
class Point
{
public:
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 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)
{
cout<<s.Area()<<endl;
}
void main()
{
Rectangle rec(3.0, 5.2, 15.0, 25.0);
fun(rec);
}
调试的错误是
C:\Program Files\Microsoft Visual Studio\MyProjects\lanshulin31\lanshulin31.cpp(22) : error C2533: 'Rectangle::Rectangle' : constructors not allowed a return type
C:\Program Files\Microsoft Visual Studio\MyProjects\lanshulin31\lanshulin31.cpp(33) : error C2264: 'Rectangle::Rectangle' : error in function definition or declaration; function not called
这是什么错误啊,高手指教

搜索更多相关主题的帖子: private include public double return 
2006-12-07 12:39



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




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

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