It's related to how the compiler matches the types of variables in an expression before carrying out the subtraction.
You can control the result either by assigning the result of the expression to a variable of the desired type, or by casting it to the required type.
1 2 3 4 5 6 7 8 9 10
int a = 10;
unsignedint b = 11;
int c = a - b;
unsignedint d = a - b;
std::cout << "a - b " << a - b << std::endl;
std::cout << "cast to int " << static_cast<int>(a - b) << std::endl;
std::cout << "cast to unsigned " << static_cast<unsignedint>(a - b) << std::endl;
std::cout << "int c " << c << std::endl;
std::cout << "unsigned int d " << d << std::endl;
a - b 4294967295
cast to int -1
cast to unsigned 4294967295
int c -1
unsigned int d 4294967295
As to why a very large number is displayed, that comes down to the way that negative numbers are represented in twos complement form.