1

I get a very weird error in my code. I created this class in C++:

class Tester{
    float f;
    Tester(float,float);
};

and i implemented it like this:

Tester::Tester(float near,float a){
    this->f=near/a;
}

i get the following error:

..\src\Tester.cpp: In constructor 'Tester::Tester(float, float)':
..\src\Tester.cpp:4:14: error: expected primary-expression before '/' token
  this->f=near/a;
              ^

when i rename near to something else the error disappears. thats not a big deal of course because i can rename the variable, but i was just curious if someone of you knows the reason.

Update:

The reason is the inlusion of windef.h. it was included by windows.h via wglext.h.

user2864740
  • 60,010
  • 15
  • 145
  • 220
tly
  • 1,202
  • 14
  • 17

1 Answers1

4

It seems that near is defined as a macro by the compiler in some header. Usually this macro is used with "near" pointers.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335