Suppose I have these 4 typedefs, where each of the 2nd parameter in
each is a simple class that just contains a different number of strings:
typedef map < char*, cctrlrec_data, ltstr > ctrlrec_table2;
typedef map < char*, ctyperec_data, ltstr > typerec_table2;
typedef map < char*, chotrec_data, ltstr > hotrec_table2;
typedef map < char*, cmtxtrec_data, ltstr > mtxtrec_table2;
I have a stream of XML data coming across a socket and I want to parse
it out into instances of cctrlrec_data, ctyperec_data, chotrec_data, or
cmtxtrec_data, which then will be stuffed into the appropriate typedef'd
map.
My parser will tell me which kind of object to instantiate, and
it produces the data for a number of each in series but does mix
them up in series.
eg: parser output is:
-- start parsing
cctrlrec_data strings
..
..
..
cctrlrec_data strings
ctyperec_data strings
..
..
..
ctyperec_data strings
chotrec_data strings
..
..
..
chotrec_data strings
cmtxtrec_data strings
..
..
..
cmtxtrec_data strings
-- done parsing
I'd like to have a pointer that I could just change to point at the
appropriate map when the parser code starts producing a different
type of output object.
A pointer to the base class seems ideal for this.
But how does one declare a pointer to the base class when that is a
template class? Can one do this? Am I completely out to lunch, & should
consider some other method of doing this? ;-)
TIA!
Eric