Can't get any code using header guards to compile in vs 2010. For example:
#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
I get this output from compiler:
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 ==========
Am i missing something obvious here? I'm quite sure i have the syntax correct. Thanks.
You can't use .
in the identifier.
Try this instead:
#ifndef SIMPLE_H
#define SIMPLE_H
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With