开发者

fatal error C1016: #if[n]def expected an identifier

开发者 https://www.devze.com 2022-12-29 01:36 出处:网络
// File: Lab13Frac.h #include <iostream> using namespace std; #ifndef \"Lab13Frac.h\" #define \"Lab13Frac.h\"
// File: Lab13Frac.h

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

// prototp开发者_StackOverflowes

#endif 


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消