This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
cpp:basic_data_types [2019/04/12 08:34] gthanos [Αυτόματη εξαγωγή τύπου δεδομένων] |
cpp:basic_data_types [2021/04/25 14:02] (current) |
||
|---|---|---|---|
| Line 50: | Line 50: | ||
| int b(3); // initial value: 3 | int b(3); // initial value: 3 | ||
| int c{2}; // initial value: 2 | int c{2}; // initial value: 2 | ||
| - | int result; | + | |
| a = a + b; | a = a + b; | ||
| - | | + | |
| - | cout << | + | b = a - c; |
| + | cout << | ||
| return 0; | return 0; | ||
| Line 70: | Line 71: | ||
| int main () | int main () | ||
| { | { | ||
| - | int a{5}; // initial value: 5 | + | int a{5}; // initial value: 5, sizeof int |
| - | long b(3); // initial value: 3 | + | long b(3); // initial value: 3 |
| - | auto result = a + b; | + | auto result = a + b; // compiler automatically extracts the variable type. |
| - | cout << result; | + | |
| + | cout << | ||
| + | cout << " | ||
| + | cout << " | ||
| return 0; | return 0; | ||
| Line 89: | Line 93: | ||
| { | { | ||
| int a{5}; // initial value: 5 | int a{5}; // initial value: 5 | ||
| - | | + | |
| - | decltype(a) result; | + | decltype(b) result; |
| - | result | + | |
| - | cout << | + | cout << |
| + | cout << " | ||
| | | ||
| return 0; | return 0; | ||