Skip to content

Commit

Permalink
typeid
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim InGee committed Nov 15, 2017
1 parent 9c37db1 commit 8782e20
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions chapter.01.basics/init-var.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <iostream>
#include <complex>
#include <vector>
#include <typeinfo>

using namespace std;

Expand Down Expand Up @@ -29,11 +30,21 @@ int main()
auto ch = 'x';
auto i = 123;
auto d = 1.2;
cout << "b= " << b << ", sizeof(b)= " << sizeof(b) << "\n";
cout << "ch= " << ch << ", sizeof(ch)= " << sizeof(ch) << "\n";
cout << "i= " << i << ", sizeof(i)= " << sizeof(i) << "\n";
cout << "d= " << d << ", sizeof(d)= " << sizeof(d) << "\n";
cout << "b= " << b
<< ", typeid(b).name()= " << typeid(b).name()
<< ", sizeof(b)= " << sizeof(b) << "\n";
cout << "ch= " << ch
<< ", typeid(ch).name()= " << typeid(ch).name()
<< ", sizeof(ch)= " << sizeof(ch) << "\n";
cout << "i= " << i
<< ", typeid(i).name()= " << typeid(i).name()
<< ", sizeof(i)= " << sizeof(i) << "\n";
cout << "d= " << d
<< ", typeid(d).name()= " << typeid(d).name()
<< ", sizeof(d)= " << sizeof(d) << "\n";

auto f = float{0.1};
cout << "f= " << f << ", sizeof(f)= " << sizeof(f) << "\n";
cout << "f= " << f
<< ", typeid(f).name()= " << typeid(f).name()
<< ", sizeof(f)= " << sizeof(f) << "\n";
}

0 comments on commit 8782e20

Please sign in to comment.