0

Can a variable be an operator

can I have a variable equal an operator. example: a = && and stuff like that

1st Jun 2017, 9:44 PM
Edward Gibson
Edward Gibson - avatar
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.
2nd Jun 2017, 2:56 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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; }
1st Jun 2017, 9:53 PM
Eligijus Silkartas
Eligijus Silkartas - avatar
0
no man ...!!
17th Jul 2017, 4:31 AM
Bansi Patel