0
Can a variable be an operator
can I have a variable equal an operator. example: a = && and stuff like that
3 odpowiedzi
+ 9
There is no datatype to store working operators, but you may store specific symbols/characters in strings and evaluate them using if-else conditions or switches. E.g.
https://code.sololearn.com/ceu6YdjX2LPc/?ref=app
That, or by using macros.
+ 5
Not really a variable, but you can do something like this:
#include <iostream>
#define add +
#define _and &&
int main() {
cout << 5 add 3; // same as 5 + 3
cout << (1 _and 0); // same as 1 && 0
return 0;
}
0
no man ...!!