.H suffix. For example,
class Foo would be defined in the file
Foo.H.
.H suffix) is to be
guarded using the
#ifndef FOO_H
#define FOO_H
.
.
#endif
style. This style is used to avoid multiple includes of the header.
.C) file. The one exception: an accessor or a mutator
method for a data member may be done inline and defined in the
header file, outside the class definition.
.C suffix. For example,
the Foo class would be implemented in the file
Foo.C.
Note that each class has two associated files -- the definition or
header file (.H) and the implementation file
(.C). Exception: a pure abstract class will have just
the header file.
main function is to be in its own file, named
after the project and with a .C suffix. For example, the
main function for project 3 would be in the file
Proj3.C.
Proj3 file.
The header file for a class presents the public interface for the class. We adopt the convention that class documentation is done in the header file. Implementation files may be documented also, but this is documentation for the programmer, not for the class user.
For an example of header file documentation, see the sample header below. You are encouraged to adopt this sample style. If you prefer your own style, that's ok, but it must meet the specifications laid out here.
Documentation of a class is to include the following information:
private. You may document a data field if necessary for
clarity.
For projects in this class, use the following coding standard:
private, protected and
public section in a class definition. private
precedes protected precedes public.
private.
const variables
globally - nothing else.
const variables for constants.
inline functions except accessors/mutators
for data members. Define inline functions in the
class header file, not in the implementation file.
virtual methods, provide a
virtual destructor.
const int MAXSIZE
class DoubleLinkNode
void SetSize(int)
int _length
int growth_rateint growthRate
Makefile or
makefile, your choice.
The grader will compile your submitted project by typing
'make,' so your makefile must correctly make your
project. This includes correct naming of the executable.
See below for an example makefile. This
example can be easily modified for each project; change the
PROJ and SOURCES definitions and make the
appropriate changes in the targets and commands.
The example makefile can be used to obtain a nice-looking printout of your code. Just type make print and a Postscript file will be produced, ready for printing on any Postscript printer.
The makefile can also be used to submit your project. As long as you have SOURCES correctly defined, it will submit all the required files. Just type make submit to submit your project.
Remember that the command lines following the target line are indented
by the TAB character, not by spaces.
# Makefile # CMSC-202 Spring 1999 Project 1 # Alan Baumgarten # Created: 26 January 1999 # Current: 26 January 1999 # PROJ = Proj1 CC = CC CCFLAGS = -g -n32 SOURCES = \ $(PROJ).C \ PrintJob.H \ PrintJob.C \ PrintQueue.H \ PrintQueue.C \ Printer.H \ Printer.C OBJECTS = \ PrintJob.o \ PrintQueue.o \ Printer.o SUBMITCLASS = cs202-01 PRINTPGM = /usr/lib/print/lptops PRINTFLAGS = -G -U -H -M2 -O0.4pt PRINTFILE = $(PROJ).ps $(PROJ): $(PROJ).C $(OBJECTS) $(CC) $(CCFLAGS) -o $(PROJ) $(PROJ).C $(OBJECTS) PrintJob.o: PrintJob.C PrintJob.H $(CC) $(CCFLAGS) -c PrintJob.C PrintQueue.o: PrintQueue.C PrintQueue.H PrintJob.H $(CC) $(CCFLAGS) -c PrintQueue.C Printer.o: Printer.C Printer.H $(CC) $(CCFLAGS) -c Printer.C print: $(SOURCES) - $(PRINTPGM) $(PRINTFLAGS) $(SOURCES) Makefile > $(PRINTFILE) submit: submit $(SUBMITCLASS) $(PROJ) $(SOURCES) Makefile clean: - rm -f *~ cleaner: - make clean; rm -f *.o cleanest: - make cleaner; rm -f $(PROJ)
/*
PrintQueue.H
PrintQueue class header file
Project 1, CMSC 202, Section 101, Spring 1999
Alan Baumgarten
Created: 21 January 1999
Current: 26 January 1999
*/
#ifndef PRINTQUEUE_H
#define PRINTQUEUE_H
/*
This class simulates a queue of print jobs.
There is no limit to the number of jobs in
the queue.
Author: Alan Baumgarten
Version: 26 January 1999
*/
class PrintQueue {
private:
char _name[21];
PrintJob* _head;
PrintJob* _tail;
public:
// Default constructor. Name is "Unnamed"
PrintQueue();
// Construct empty PrintQueue with specified name
// Param queue_name: Name of the queue (20 chars max.)
PrintQueue (char* queueName);
// Add a job to the queue
// Param job_ptr: Pointer to the PrintJob
// to be added
void Enqueue (PrintJob* job_ptr);
// Remove a job from the queue
// Returns: Pointer to first job in queue
// Pre-condition: The queue must not be empty
PrintJob* Dequeue ();
// Check to see if queue is empty
// Returns: True if empty, false if not
int IsEmpty();
};
#endif