致命错误C1016:#if [n] def期望一个标识符

时间:2010-04-28 23:44:53

标签: c++ compiler-errors

// File: Lab13Frac.h

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

// prototpes

#endif 

2 个答案:

答案 0 :(得分:7)

标识符不应该在引号中。此外,按惯例,它应该全部上限。

// 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

答案 1 :(得分:1)

以下是我将如何做到这一点

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

#include <iostream>

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

// prototpes
#endif //LAB13FRAC_H

您不能将字符串用作标识符,请使用文字,就好像它是变量名一样。 另外,您应该在#endif旁边发表评论,告诉读者你是谁#endif