0
question about the way of coding in example of the program for C++ sizeof ....
why we must to declare var ?? the code :..... cout << "char: " << sizeof(char) << endl; cout << "int: " << sizeof(int) << endl; cout << "float: " << sizeof(float) << endl; cout << "double: " << sizeof(double) << endl; int var = 50; cout << "var: " << sizeof(var) << endl; /* Outputs char: 1 int: 4 float: 4 double: 8 var: 4 */
2 Respostas
0
var is a variable that will allow you to store a data type in it. var can be 10, 20, 5. You need to declare the type of data type the variable is because you can add int variables together, but not a string and int. Each has its own functions etc. That requires he variable to be a certain type. Same for declaring an array. You can use the functions for arrays only once you have declared it as an array.
0
Thank you so much