.H or .h It's a good
idea, but not required, to name this file after the class.
For example, class Foo would be defined in a file named
Foo.H or Foo.h
#ifndef FOO_H
#define FOO_H
.
.
#endif
style. This style is used to avoid multiple includes of the header.
.C or .CC or
.cpp
It's a good idea but not required to name this file after the class.
For example, the Foo class
would be implemented in a file named Foo.C or
Foo.CC or Foo.cpp.
Foo.h refers to an
ostream entity and a string entity. Then,
definitely do include iostream.h and mystring.h
in Foo.h. Now, suppose the implementation file
Foo.C refers to an ostream entity, but not
a string entity. Then Foo.C should include
Foo.h and iostream.h, but not
mystring.h. Note that iostream.h is included
even though its inclusion is also caused by including Foo.h.
Guarded header files keep this from causing multiple definition and your
code becomes cleaner and more readable.
main function is to be in its own file. The
file extension must be .C, .CC, or
.cpp It's a
good idea, but not required to name the file after the project.
For example, the main function
for project 3 would be in a file named
Proj3.C, Proj3.CC or Proj3.cpp
proj3 file. This is very important because the grader
will look for that file to run your program. The grader will not
run a.out or any other executable. The executable name
is controlled by your makefile - get it right. Do not submit your
executable, the grader will construct it by using your makefile.
For projects in this class, use the following coding standard:
private, protected and
public section in a class definition. public
comes first, followed by protected and private,
in that order.
friend designation is to be used judiciously.
Functions, operators, and classes should only be specified as
friend
if they are intended as part of the interface to the
class they are a
friend
of. You must pay attention to good
design in your projects; you should not be using friend
simply to avoid using the proper accessor and mutator functions. Projects
which abuse friend will lose points proportionate to the
degree of abuse.
private.
const variables globally - nothing else.
#define) for constants. Use
const variables for constants.
virtual methods, provide a
virtual destructor.
const method. Example:
int getSize() const
void. Example:
void setSize(int newsize)
Makefile or
makefile, your choice. No other names are acceptable
for your makefile.
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.
A number of tutorials on makefiles are available. One is the UCS tutorial. Another is an excerpt from the GNU tutorial.