and and or are valid C++ operator ( as well as && and || )
True, although they are considered to be the alternative rather than the primary.
Last edited on
@Moschops
As Bazzy said, they're still valid. It's like saying:
1 2 3 4 5 6 7
|
#define BEGIN { // Doesn't change the way '{' operates.
#define END } // Doesn't change the way '}' operates.
void Function( void )
BEGIN
// ...
END
|
Last edited on
Because they are basically macros AFAIK.
they can't be standard, are they in a certain header? I get undeclared identifier errors when I try that.
Last edited on
monster_negative, what do you mean? I'm supposed to make it a variable?
that was pseudo code. Check if the monster hp is below 0.
They should produce the same token.
This compiles and prints "ok" using g++ 4.5.2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
struct S
{
void operator and ( S )
{
std::cout << "ok" << std::endl;
}
};
int main()
{
S a,b;
a && b;
}
|
(edit) should work as well in an implementation where
and is a macro as long as that macro is defined and expands to &&
Last edited on
Interesting. For the macro version, I would expect the spaces before and after "and" in "operator and (" to be required.
BTW, using g++ this #define and &&
will give the following error: "and" cannot be used as a macro name as it is an operator in C++
@Nuc
I think your arrows are pointing the wrong way, your code specifies the condition greater than or equal to. Do you mean less than or equal to?
<=
Last edited on