.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.
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. 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. public
comes first, followed by protected and private,
in that order.
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)
const int MAXSIZE
class DoubleLinkNode class Matrix
void setSize(int) int inverse(int) Matrix mat int arraySize
int _length. Remember, all class data members must
be private.
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.