标题:帮忙看看这个程序出什么问题了
取消只看楼主
lindayanglong
Rank: 1
等 级:新手上路
帖 子:86
专家分:0
注 册:2008-3-9
 问题点数:0 回复次数:1 
帮忙看看这个程序出什么问题了
下面的程序是为了说明truct也能和class一样,但是不知道为什么会有这么多错误,请高手帮忙看看
#include<iostream>
using namespace std;
enum breed{ golden, cairn,dandie,shetland,doberman, lab};
struct mannal
{
public:
    mammal():itsage(2),itsweigh(5){}
    ~mammal(){}

    int getage()const
    {
        return itsage;
    }
    void setage(int age)
    {
        itsage=age;
    }
    int getweight() const
    {
        return itweight;
    }
    void setweight(int weight)
    {
        itsweight=weight;
    }
    void speak()const
    {
        cout<<"mammal sound"<<endl;
    }
    void sleep()const
    {
        cout<<"I'm sleeping"<<endl;
    }
protected:
     int itsage;
    int itsweight;
};
struct dog:public mammal
{
public:
    dog():itsbreed(golden){}
    ~dog(){};
    breed getbreed()const
    {
        return itsbreed;
    }
    void setbreed(breed breed)
    {
        itsbreed=breed;
    }
    void wagtail()const
    {
        cout<"tail wagging"<<endl;
    }
    void begforfood()const
    {
        cout<<"begging for food"<<endl;
    }

private:
    breed itsbreed;
};
void main()
{
    dog fido;
    fido.speak();
    fido.wagtail();
    cout<<"fido is "<<fido.getage()<<"years old"<<endl;

}
搜索更多相关主题的帖子: include golden public return 
2008-09-10 16:09
lindayanglong
Rank: 1
等 级:新手上路
帖 子:86
专家分:0
注 册:2008-3-9
得分:0 
谢谢楼上的,不过还是错很多
2008-09-11 11:33



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




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

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