dog.cc
来自「做为SD0609的一员,我扎实的基础是如何打出来的,来看看我那时连猴子选大王都不」· CC 代码 · 共 94 行
CC
94 行
#include <iostream>using namespace std;enum BREED { GOLDEN, CAIRN, DANDIE, SHETLAND, DOBERMAN, LAB };class Mammal{protected: int itsAge; int itsWeight;public: // constructors Mammal():itsAge(0),itsWeight(100) { cout << "Mammal()" << endl; } ~Mammal() { cout << "~Mammal()" << endl; } //accessors int GetAge() const { return itsAge; } void SetAge(int a) { itsAge = a; } int GetWeight() const { return itsWeight; } void SetWeight( int w ) { itsWeight = w; } //Other methods void Speak() const { cout << "Mammal speak" << endl; } void Sleep() const { cout << "Mammal sleep" << endl; }};class Dog : public Mammal{protected: BREED itsBreed;public: // Constructors Dog():itsBreed(LAB) { // itsAge = 0; // itsWeight = 100; cout << "Dog()" << endl; } ~Dog() { cout << "~Dog()" << endl; } // Accessors BREED GetBreed() const { return itsBreed; } void SetBreed(BREED b) { itsBreed = b; } // Other methods void WagTail() { cout << "Dog wags tail" << endl; } void BegForFood() { cout << "Dog begs for food" << endl; }};int main(){ Dog od; return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?