previous | index | next

More Files

To test the classes, we must have a main function, which is not a member of any class, so it goes in a separate .cpp file.

We will put our test code in duds-main.cpp, shown at right.

duds-main.cpp requires the types Item, OxfordShirtInfo, and ChinoInfo, which are defined either directly or indirectly by duds.H, shown at right.

duds-main.cpp

#include "duds.H"

/*
 * Test code for the online shopping store
 */
int main(int argc, char** argv) {
    
  Item item = new OxfordShirtInfo(49.99, "Navy blue", 15, 33);
  item->display();
  item = new ChinoInfo(69.99, "Khaki", 36, 34, false);
  item->display();
}

duds.H

#ifndef _DUDS_H
#define _DUDS_H

typedef class ItemInfo* Item;
typedef class OxfordShirtInfo* OxfordShirt;
typedef class ChinoInfo* Chino;

#include "item.H"
#include "shirt.H"
#include "chino.H"

#endif /* _DUDS_H */

previous | index | next