s = g(s);
cout ‹‹ s.p ‹‹ "\n";
}
b6_7.cxx
#include ‹stream.hxx›
#include ‹string.h›
struct pair {
char * name;
int val;
};
class assoc {
pair * vec;
int max;
int free;
public:
assoc(int);
int& operator[](char*);
void print_all();
};
assoc::assoc(int s)
{
max = (s‹16) ? s : 16;
free = 0;
vec = new pair[max];
}
int& assoc::operator[](char * p)
/*
maintain a set of "pair"s
search for p,
return a reference to the integer part of its "pair"