animal.cpp

来自「C++上机课的习题答案」· C++ 代码 · 共 58 行

CPP
58
字号
// Chapter 10 of C++ How to Program
// Debugging Problem (animal.cpp)

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::string;

#include "animal.h"

// default constructor
Animal::Animal( int h, int w )
{
   height = h;
   weight = w;

} // end class Animal constructor

// function print definition
 void Animal::print() const
{
   //cout << "This animal's height and weight are as follows:\n"
       // << "Height: " << height << "\tWeight: " << weight
        //<< endl << endl;

} // end function print

// return height
 int Animal::getHeight() const 
{
   return height;

} // end function getHeight

// return weight
 int Animal::getWeight() const 
{
   return weight;

} // end function getWeight

// function setHeight definition
 void Animal::setHeight( int h ) 
{
   height = h;

} // end function setHeight

// function setWeight definition
 void Animal::setWeight( int w ) 
{
   weight = w;

} // end function setWeight


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?