Listing 1: Printing using the generic class BasePrinter
#include <stdio.h>
#include "printers.hpp"
void main(void)
{
BasePrinter *printer;
int choice = 1;
printf("Printing Example:\n");
printf("1 - file I/O, 2 - Raw GDI, 3 - GDI\n");
printf("Choice:");
scanf("%d",&choice);
switch (choice) {
case 1: printer = new DirectPrinter(); break;
case 2: printer = new WinDirPrinter(); break;
case 3: printer = new WinGDIPrinter(); break;
}
printer->SetFontPointSize();
printer->PrintLine("Dave's Printing Example");
printer->PrintLine(" ** Hello Printer ** ");
printer->EjectPaper();
delete printer;
};
//End of File