C++上机课的习题答案
源代码在线查看: debugging10.cpp
软件大小: |
65 K |
上传用户: |
libhzsmo |
|
|
关键词: |
|
下载地址: |
免注册下载 普通下载
|
|
// Chapter 10 of C++ How to Program
// Debugging Problem (debugging10.cpp)
#include
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 cin >> height;
a->setHeight( height );
cout cin >> weight;
a->setWeight( weight );
height = a->getHeight();
weight = a->getWeight();
cout
} // end function setHeightWeight