C++ is a strongly typed language, each variablemust have a type associated with it.
The auto keyword is a fancy thing designed to be helpful for much complicated and advanced things, where it is easier to let the compiler do it, rather than a human making a mistake. In other words it wasn't invented solely because coders didn't want to have to type int again.
One can't omit the variable name sum, because the compiler needs something to associate it's value with. All variables should have a value, that is why it is so important to always initialise the variables with something.
because sum is a variable and every variable in C++ has to have a type as C++ is (quite) a strongly typed language. In addition to auto, as Peter shows, you could also use decltype:
1 2 3 4 5 6 7 8 9
#include <iostream>
int main()
{
int a {5}; //braced initialization / uniform initialization
int b {6};
decltype(a+b) sum = a + b;
std::cout << sum << "\n";
}
there are a dozen types of integer as well (many redundant).
say you have this one..
char c = 100;
char b = 100;
d = c+b; //what is d? 200 won't fit into char, the max is 128! int is too big, wastes space. short is about right, but did you want a short? How would it know?
I do not know of any weakly typed languages that have high performance on par with C++. They err on the side of allocating the biggest thing possible which is very inefficient for a number of reasons when your programs become complicated.