Asg 0.5: List of pointers to data_t objects

Objectives

To implement a data_t object, read a file, and add data_t objects to a list (std::vector).

Assignment

  1. Write C++ code to define a data_t class (object) that will hold the following two data members:
  2. Create two files: data.h that holds the object interface and data.cpp that holds the object implemantation.
  3. The main.cpp test driver program (see below) reads a data file (redirected from std::cin), creates a data_t object from each pair of string and numbers, and adds them to a list. It then prints them out and deletes the list. Once your program successfully compiles (using the Makefile provided below), you should be able to test the program by executing this command on the command line:

Details

  1. Your data_t object should provide the following:

Requirements

  1. Rewrite Assignment 00's main() routine such that it now uses a list of pointers to data_t (std::vector<data_t* >).

Input

  1. The listdata.txt file used to test the above program is:
    Mike    1234
    Bill    3212
    Sarah   1321
    John    1021
    Carol   3223
    Debbie  4231
    Gary    9321
    Ann     1231
    Dale    7231
    Lynn    8133
    Patty   9999
    	

Output

  1. Expected output with the above input file is:
    Mike 1234
    Bill 3212
    Sarah 1321
    John 1021
    Carol 3223
    Debbie 4231
    Gary 9321
    Ann 1231
    Dale 7231
    Lynn 8133
    Patty 9999
    *** printing records
    Mike 1234
    Bill 3212
    Sarah 1321
    John 1021
    Carol 3223
    Debbie 4231
    Gary 9321
    Ann 1231
    Dale 7231
    Lynn 8133
    Patty 9999
    *** printing records again
    Mike 1234
    Bill 3212
    Sarah 1321
    John 1021
    Carol 3223
    Debbie 4231
    Gary 9321
    Ann 1231
    Dale 7231
    Lynn 8133
    Patty 9999
    *** deleting records
    *** initializing new records
    *** deleting records again
    *** done
    	

Supplemental

  1. Here is a Makefile that you can use to compile the project:
    .SUFFIXES: .c .o .cpp .cc .cxx .C
    
    UNAME = $(shell uname)
    PLATFORM = $(shell uname -p)
    
    CC = g++
    COPTS = -g -Wall
    
    INCDIR =
    LIBDIR =
    
    ifeq ("$(shell uname)", "Linux")
    LIBS = -lm
    else
    ifeq ("$(shell uname)", "Darwin")
    LIBS = -framework Foundation -lstdc++
    endif
    endif
    
    .c.o:
    	$(CC) -c $(INCDIR) $(COPTS) -o $@ $<
    
    .cpp.o:
    	$(CC) -c $(INCDIR) $(COPTS) -o $@ $<
    
    all : main
    
    OBJECTS = \
    data.o
    
    main : $(OBJECTS) main.o
    	$(CC) -o $@ $(INCDIR) $(COPTS) $(OBJECTS) $@.o $(LIBDIR) $(LIBS)
    
    data.o: data.h data.cpp
    
    clean :
    	rm -f *.o
    	rm -rf main main.app
    	

Turn in

Turn in all of your code, in one tar.gz archive of your asg##/ directory, including:
  1. A README file containing
    1. Course id--section no
    2. Name
    3. Brief solution description (e.g., program design, description of algorithm, etc., however appropriate).
    4. Lessons learned, identified interesting features of your program
    5. Any special usage instructions
  2. Makefile
  3. source code (.h headers and .cpp source)
  4. object code (do a make clean before tar)

How to hand in

See handin notes

Grading scheme