A SERVICE OF

logo

T mplate class namee
The document class should be the document class you want to use for data
containment. The view class should be the view class you want to use to
display the data contained in the document class. The template class name
should be indicative of the function of the template. It cannot be a C++
keyword (such as int, switch, and so on) or the name of any other type in
the application.
For example, suppose you’ e two document classes—one calledv
TPlotDocument, which contains graphics data, and another called
TDataDocument, which contains numerical data. Now suppose you have
four view classes, two for each document class. For TPlotDocument, you
have TPlotView, which displays the data in a TPlotDocument object as a
drawing, and THexView, which displays the data in a TPlotDocument object
as arrays of hexadecimal numbers. For TDataDocument, you have
TSpreadView, which displays the data in a TDataDocument object much like
a spreadsheet, and TCalcView, which displays the data in a TDataDocument
object after performing a series of calculations on the data.
T associate the document classes with their views, you would use theo
DEFINE_DOC_TEMPLA E_CLASS macro. The code would lookT
something like this:
DEFINE_DOC_TEMPLATE_CLASS(TPlotDocument, TPlotView, TPlotTemplate);
DEFINE_DOC_TEMPLATE_CLASS(TPlotDocument, THexView, THexTemplate);
DEFINE_DOC_TEMPLATE_CLASS(TDataDocument, TSpreadView, TSpreadTemplate);
DEFINE_DOC_TEMPLATE_CLASS(TDataDocument, TCalcView, TCalcTemplate);
As you can see from the first line, the existing document class
TPlotDocument and the existing view class TPlotView are brought together
and associated in a new class called TPlotT mplate. The same thing happense
in all the other lines, so that you have four new classes, TPlotT mplate,e
THexT mplate, TSpreadT mplate, and TCalcT mplate. The next sectione e e
describes how to use these new classes you’ e created.v
Once you’ e defined a template class, you can create any number ofv
Creating template
instances of that class. Y u can use template class instances to provideo
class instances
different descriptions of a template, search for different default file names,
look in different default directories, and so on. Y u can affect all theseo
things when calling the template class constructor.
The signature of a template class constructor is always the same:
TplName name(LPCSTR desc, LPCSTR filt, LPCSTR dir, LPCSTR ext, long flags);
202
OWL P ogrammer’ Guider s