Skip to content

Commit 69a33dd

Browse files
typeid for vector
1 parent 324a979 commit 69a33dd

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <iostream>
22
#include <typeinfo>
33
#include <string>
4+
#include <vector>
45

56
using namespace std;
67

@@ -12,15 +13,21 @@ int main()
1213
int* i3, i4; //i3 will be treated as pointer, but i4 not
1314
float f1;
1415
double d1;
15-
std::string s1;
16+
string s1;
17+
vector<int> vi;
18+
vector<vector<int>> vvi;
19+
vector<string> vs;
1620

17-
cout << typeid(i1).name() << endl; //Pi
18-
cout << typeid(i2).name() << endl; //Pi
19-
cout << typeid(i3).name() << endl; //Pi
20-
cout << typeid(i4).name() << endl; //i
21-
cout << typeid(f1).name() << endl; //f
22-
cout << typeid(d1).name() << endl; //d
23-
cout << typeid(s1).name() << endl; //NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
21+
cout << typeid(i1).name() << endl; //Pi
22+
cout << typeid(i2).name() << endl; //Pi
23+
cout << typeid(i3).name() << endl; //Pi
24+
cout << typeid(i4).name() << endl; //i
25+
cout << typeid(f1).name() << endl; //f
26+
cout << typeid(d1).name() << endl; //d
27+
cout << typeid(s1).name() << endl; //NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
28+
cout << typeid(vi).name() << endl; //St6vectorIiSaIiEE
29+
cout << typeid(vvi).name() << endl; //St6vectorIS_IiSaIiEESaIS1_EE
30+
cout << typeid(vs).name() << endl; //St6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE
2431

2532
return 0;
2633
}

0 commit comments

Comments
 (0)