标题:有哪个高手可以帮我看看这个程序哪里有问题吗?谢谢
取消只看楼主
chuxuechengxu
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-6-18
 问题点数:0 回复次数:1 
有哪个高手可以帮我看看这个程序哪里有问题吗?谢谢
#include<iostream>
using namespace std;
class shape
{
public:
    shape(){}
    ~shape(){}
    virtual float GetArea(){return -1;}
};
class Rectangle:public shape
{
public:
    Rectangle(int len,int wid){};
    ~Rectangle(){};
    virtual float GetArea(){return len*wid;}
private:
    int wid;
    int len;
};
void main()
{
    shape *sp;
    sp = new Rectangle(2,3);
    cout<<"the area of the rectangle is"<<sp->GetArea()<<endl;
delete sp;
}
搜索更多相关主题的帖子: Rectangle shape int 
2008-06-18 08:42
chuxuechengxu
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-6-18
得分:0 
恩,谢谢
2008-06-25 17:00



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




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

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