views:

183

answers:

2
// File: Lab13Frac.h

#include <iostream>
using namespace std;
#ifndef "Lab13Frac.h"
#define "Lab13Frac.h"

// prototpes

#endif 
+7  A: 

The identifier should not be in quotes. Also, it should be in all caps by convention.

// File: Lab13Frac.h

#ifndef LAB13FRAC_H
#define LAB13FRAC_H

#include <iostream>
using namespace std;
// The above line is not recommended in header files
// because it may cause namespace collisions.
// See http://www.parashift.com/c++-faq-lite/coding-standards.html#faq-27.5

// Prototypes

#endif
In silico
Depending on coding style, it's also possible to write (for example) `#ifndef _LAB13FRAC_H_ ... ` and sometimes `#endif // _LAB13FRAC_H_`
Kotti
@Kotti: Except those identifiers are reserved for the compiler. (Any name starting with an underscore followed by another underscore or capital letter are reserved.)
GMan
@GMan Know about the double underscore, but it's the first time when I've heard about `_X....` being reserved. Could you point to some docs to read?
Kotti
@Kotti, See C++0X FCD 17.6.3.3.2.1:Certain sets of names and function signatures are always reserved to the implementation:— Each name that contains a double underscore _ _ or begins with an underscore followed by an uppercaseletter (2.12) is reserved to the implementation for any use.— Each name that begins with an underscore is reserved to the implementation for use as a name in theglobal namespace.
Nathan Ernst
@Kotti: http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier/228797#228797
GMan
@Gman, Nathan Thank you
Kotti
+1  A: 

Here's how I would do that

// File: Lab13Frac.h
#ifndef LAB13FRAC_H
#define LAB13FRAC_H

#include <iostream>

using namespace std; //You shouldn't do this anyway...

// prototpes
#endif //LAB13FRAC_H

You can't use a string as an identifier, use a literal as if it is a variable name. Also, you should put a comment next to #endif to tell who reads what you are #endifing

klez