// File: Lab13Frac.h
#include <iostream>
using namespace std;
#ifndef "Lab13Frac.h"
#define "Lab13Frac.h"
// prototpes
#endif
views:
183answers:
2
+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
2010-04-28 23:48:19
Depending on coding style, it's also possible to write (for example) `#ifndef _LAB13FRAC_H_ ... ` and sometimes `#endif // _LAB13FRAC_H_`
Kotti
2010-04-28 23:51:47
@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
2010-04-28 23:52:44
@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
2010-04-28 23:55:41
@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
2010-04-29 00:01:28
@Kotti: http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier/228797#228797
GMan
2010-04-29 00:01:42
@Gman, Nathan Thank you
Kotti
2010-04-29 00:04:51
+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 #endif
ing
klez
2010-04-28 23:50:53