Dan*_*atz 5 c++ compiler-errors visual-studio-2010 compiler-warnings
无法使用标头保护程序在vs 2010中编译任何代码.例如:
#ifndef SIMPLE.H
#define SIMPLE.H
#include <iostream>
class Place {
private:
int m_xplace;
int m_yplace;
Place(){}
public:
Place(int x, int y) : m_xplace(x), m_yplace(y) {}
void Move(int x, int y);
void set_place(int x, int y) {m_xplace = x, m_yplace = y;}
int get_place_x() {return m_xplace;}
int get_place_y() {return m_yplace;}
};
#endif
Run Code Online (Sandbox Code Playgroud)
我从编译器得到这个输出:
1>------ Build started: Project: 1, Configuration: Release Win32 ------
1>e:\projects\1\1\simple.h(1): warning C4067: unexpected tokens following preprocessor directive - expected a newline
1>e:\projects\1\1\simple.h(2): error C2008: '.' : unexpected in macro definition
1>e:\projects\1\1\simple.h(1): warning C4067: unexpected tokens following preprocessor directive - expected a newline
1>e:\projects\1\1\simple.h(2): error C2008: '.' : unexpected in macro definition
==========
Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Run Code Online (Sandbox Code Playgroud)
我错过了一些明显的东西吗?我很确定我的语法是正确的.谢谢.
Mys*_*ial 16
您不能.在标识符中使用.
试试这个:
#ifndef SIMPLE_H
#define SIMPLE_H
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4121 次 |
| 最近记录: |