User Tools

Site Tools


cpp:basic_data_types

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
cpp:basic_data_types [2019/04/12 08:37] – [Αυτόματη εξαγωγή τύπου δεδομένων] gthanoscpp:basic_data_types [2021/04/25 15:02] – [Αυτόματη εξαγωγή τύπου δεδομένων] gthanos
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;            // initial value undetermined+
  
   a = a + b;   a = a + b;
-  result = a - c; +  cout << "a: " << a << endl;  // endl stands for newline 
-  cout << result;+  b = a - c;               
 +  cout << "b: " << b << endl;
  
   return 0;   return 0;
Line 73: Line 74:
   long b(3);              // initial value: 3  sizeof long   long b(3);              // initial value: 3  sizeof long
  
-  auto result = a + b;    // compiler automatically extracts the result'type. +  auto result = a + b;    // compiler automatically extracts the variable type. 
-  cout << result << endl;+   
 +  cout << "sizeof(result): " << sizeof(result) << endl; 
 +  cout << "sizeof(int): " << sizeof(int) << endl; 
 +  cout << "sizeof(long): " << sizeof(long) << endl;
  
   return 0;   return 0;
Line 92: Line 96:
   decltype(b) result;   decltype(b) result;
  
-  result = a + b+  cout << "sizeof(result): " << sizeof(result) << endl
-  cout << result << endl;+  cout << "sizeof(int): " << sizeof(int) << endl; 
 +  cout << "sizeof(long): " << sizeof(long) << endl;
      
   return 0;   return 0;
cpp/basic_data_types.txt · Last modified: 2021/04/25 14:02 (external edit)