I saw alternative operators (like and
, or
, not
etc.) when browsing cppreference.
They are alternatives to "normal" operators like &&
, ||
, !
etc.
I examined the assembly for code that uses &&
and and
. Both versions generated the same assembly.
Code :
#include <iostream>
int n = 1;
int main()
{
// if(n > 0 && n < 5)
if(n > 0 and n < 5)
{
std::cout << "n is small and positive\n";
}
}
So my questions are:
- What is the difference between the
&&
andand
operators? - Where and when do I use
and
over&&
? - If there is no difference, then why does C++ introduce alternative operators (like
and
,or
,not
etc.)?