#!/bin/sh
# This is a shar archive.
# The rest of this file is a shell script which will extract:
#
# 7_1.c 7_1b.c 7_1c.c 7_1d.c 7_1ex.c makefile tst1.c tst1.cmp tst2.c tst2.cmp
#
# To extract the files from this shell archive file simply
# create a directory for this file, move the archive file
# to it and enter the command
#
#	sh filename
# 
# The files will be extracted automatically.
# Note: Do not use csh.
#
# Archive created: Mon Jul 30 23:11:59 EDT 1990
#
echo x - 7_1.c
sed 's/^X//' > 7_1.c << '!EOF!'
/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */
class der1: public base
{
public:
    void iam() { cout << "der1\n"; }
};

class der2: public base
{
public:
    void iam() { cout << "der2\n"; }
};
!EOF!
ls -l 7_1.c
echo x - 7_1b.c
sed 's/^X//' > 7_1b.c << '!EOF!'
/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */
/* declare each variable using a */
/* different class for each */
base a;
der1 b;
der2 c;
!EOF!
ls -l 7_1b.c
echo x - 7_1c.c
sed 's/^X//' > 7_1c.c << '!EOF!'
/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */
// call iam() forz each variable
// using a pointer to the base class
base *bp = &a;
bp -> iam();
bp = &b;
bp -> iam();
bp = &c;
bp -> iam();
!EOF!
ls -l 7_1c.c
echo x - 7_1d.c
sed 's/^X//' > 7_1d.c << '!EOF!'
/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */
// call iam() for each variable
a.iam();
b.iam();
c.iam();
!EOF!
ls -l 7_1d.c
echo x - 7_1ex.c
sed 's/^X//' > 7_1ex.c << '!EOF!'
/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */
class base {
public:
    virtual void iam() { cout << "base\n"; }
};
!EOF!
ls -l 7_1ex.c
echo x - makefile
sed 's/^X//' > makefile << '!EOF!'
CC= CC -I. -I../../CC

all: tst1 tst2

tst1: 7_1.c tst1.c
	$(CC) tst1.c -o tst1

tst2: 7_1.c tst2.c
	$(CC) tst2.c -o tst2

CMP= tst1.cmp tst2.cmp
OUT= tst1.out tst2.out

tst1.out: tst1 ; tst1 > tst1.out
tst2.out: tst2 ; tst2 > tst2.out

test: $(OUT) $(CMP)
	cmp tst1.out tst1.cmp
	cmp tst2.out tst2.cmp
	@echo test done
!EOF!
ls -l makefile
echo x - tst1.c
sed 's/^X//' > tst1.c << '!EOF!'
/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */
#include <stream.h>

#include "7_1ex.c"
#include "7_1.c"

void pr(base *b)
{
    b->iam();
}

main()
{
#include "7_1b.c"
    // call iam() for each variable
    pr(&a);
    pr(&b);
    pr(&c);
    return 0;
}
!EOF!
ls -l tst1.c
echo x - tst1.cmp
sed 's/^X//' > tst1.cmp << '!EOF!'
base
der1
der2
!EOF!
ls -l tst1.cmp
echo x - tst2.c
sed 's/^X//' > tst2.c << '!EOF!'
/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */
#include <stream.h>

#include "7_1ex.c"
#include "7_1.c"

main()
{
#include "7_1b.c"
#include "7_1c.c"
    return 0;
}
!EOF!
ls -l tst2.c
echo x - tst2.cmp
sed 's/^X//' > tst2.cmp << '!EOF!'
base
der1
der2
!EOF!
ls -l tst2.cmp
# The following exit is to ensure that extra garbage 
# after the end of the shar file will be ignored.
exit 0
