7 1 動物世界 15分

2021-10-04 08:46:28 字數 1374 閱讀 2481

補充程式 :

1、實現mammal類的方法

2、由mammal類派生出dog類,在dog類中增加itscolor成員(color型別)

3、dog類中增加以下方法:

constructors: dog()、dog(int age)、dog(int age, int weight)、dog(int age, color color)、 dog(int age, int weight, color color)、~dog()

accessors: getcolor()、setcolor()

other methods: wagtail()、begforfood() ,並實現以上這些方法 。

4、補充主函式的問號部分,並執行程式,檢查輸出是否合理。

enum color;

class mammal

無按照程式格式輸出。

在這裡給出一組輸入。例如:

無在這裡給出相應的輸出。例如:

mammal is speaking…

the dog is wagging its tail…

yorkie is 3 years old.

dobbie weighs 20 pounds.

enum color

;#include

using

namespace std;

class

mammal

;mammal

(int age)

mammal

(int age,

int weight)

//accessors

intgetage()

const

intgetweight()

const

void

setweight

(int weight)

//other methods

protected

:int itsage;

int itsweight;};

class

dog:

public mammal

void

wagtail()

dog(

)dog

(int age)

:mammal

(age)

dog(

int age,

int weight)

:mammal

(age,weight)

dog(

int age,

int weight,color x)

:mammal

(age,weight)};

intmain()

5 7 2 動物世界 15分

1 實現mammal類的方法 2 由mammal類派生出dog類,在dog類中增加itscolor成員 color型別 3 dog類中增加以下方法 constructors dog dog int age dog int age,int weight dog int age,color color ...

PTA 動物世界 15 分 (繼承)

補充程式 1 實現mammal類的方法 2 由mammal類派生出dog類,在dog類中增加itscolor成員 color型別 3 dog類中增加以下方法 constructors dog dog int age dog int age,int weight dog int age,color c...

西加加 7 1 動物世界

補充程式 1 實現mammal類的方法 2 由mammal類派生出dog類,在dog類中增加itscolor成員 color型別 3 dog類中增加以下方法 constructors dog dog int age dog int age,int weight dog int age,color c...