// Templates helped. // I've now got one set of functions that work nicely on both // animals and humans, but I had to forget about numbers, there's // no way to define a print() method for ints. #include #include struct animal { string name, species; int weight, price; animal(string n, string s, int w, int p) { name=n; species=s; weight=w; price=p; } void print() { cout << " " << name << "/" << species << ":" << weight << "g," << price << "c\n"; } }; struct human { string name; int weight, phone; human(string n, int w, int p) { name=n; weight=w; phone=p; } void print() { cout << " " << name << ", " << weight << " lbs, " << phone << "\n"; } }; template void printall(T * * data, int N) { for (int i=0; iprint(); } template T * reprice(T * a) { a->price = (int)(a->price*1.1 + 0.5); return a; } template T * fatten(T * a) { a->weight = (int)(a->weight*1.2 + 0.5); return a; } template void map(T * f(T *), T * * data, int N) { for (int i=0; i