C++面向对象程序设计教程(第3版)—-陈维兴,林小茶课后习题答案 下载本文

4.16

4

4.17

(1,2)

5,6

(6,9)

4.18

class base1

class base2

class level2

class base2

class level1

class toplevel.

精选范本

4.19

#include using namespace std; #include class table { public:

table(int p, int q) { i = p; j = q; }

void ascii(void); protected: int i, j; };

void table::ascii() {

int k = 1;

.

精选范本

.

for(; i <= j; i++) {

cout << setw(4) << i << \ \ << (char)i; if((k) == 0) {

cout << \; } k++; }

cout << \; }

class der_table:public table { public:

der_table(int p, int q, char *m):table(p,q) {

c = m; }

void print(); protected: char *c; };

精选范本

.

void der_table::print() {

cout << c <<\; table::ascii(); } int main() {

der_table ob('a', 'z', \); ob.print(); return 0; }

4.20

#include using namespace std; #include

class area_c1 {

精选范本