debugging10.cpp.txt

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

TXT
55
字号
// Chapter 10 of C++ How to Program
// Debugging Problem (debugging10.cpp)

#include <iostream>

using std::cout;
using std::endl;
using std::cin;
using std::string;

#include "animal.h"
#include "lion.h"
#include "dog.h"

void setHeightWeight( Animal * );

int main()
{
   Dog dog1( 60, 120, "Fido" );
   Lion lion1( 45, 300 );

   setHeightWeight( &lion1 );
   setHeightWeight( &dog1 );

   system("PAUSE");
   return 0;

} // end main

// function setHeightWeight definition
void setHeightWeight( Animal *a )
{
   int height;
   int weight;

   a->print();
   cout << "Enter a new height (using standard units): ";
   cin >> height;
   a->setHeight( height );

   cout << "Enter a new weight (using standard units): ";
   cin >> weight;
   a->setWeight( weight );

   height = a->getHeight();
   weight = a->getWeight();

   cout << "Here are the new height and weight values:\n"
        << height << endl
        << weight << endl << endl;

} // end function setHeightWeight


⌨️ 快捷键说明

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