00001 // From 00002 // http://en.wikipedia.org/wiki/Prototype_pattern 00003 00004 #include "Prototype.h" 00005 #include "Record.h" 00006 #include "CarRecord.h" 00007 #include "BikeRecord.h" 00008 #include "PersonRecord.h" 00009 #include "RecordFactory.h" 00010 00011 int main() 00012 { 00013 RecordFactory* poRecordFactory = new RecordFactory(); 00014 00015 Record* poRecord; 00016 poRecord = poRecordFactory->CreateRecord(CAR); 00017 poRecord->Print(); 00018 delete poRecord; 00019 00020 poRecord = poRecordFactory->CreateRecord(BIKE); 00021 poRecord->Print(); 00022 delete poRecord; 00023 00024 poRecord = poRecordFactory->CreateRecord(PERSON); 00025 poRecord->Print(); 00026 delete poRecord; 00027 00028 delete poRecordFactory; 00029 return 0; 00030 } 00031 00032 /*Output 00033 Car Record 00034 Name : Ferrari 00035 Number: 5050 00036 00037 Bike Record 00038 Name : Yamaha 00039 Number: 2525 00040 00041 Person Record 00042 Name : Tom 00043 Age : 25 00044 00045 */