c++11 - how does the below code output 3? (how does the below code read?) -
the specific part not understand how -a in if statement changes -3 3. can explain how -a changes a = -3 a = 3?
#include <iostream> int main(){ signed = -3; if (a < 0){ std::cout << -a << std::endl; } else { std::cout << << std::endl; } system("pause"); return 0; }
it's example of unary negative, when a=-3 (which less 0, code enters if block) -a -(-3) 3.