-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto.cpp
More file actions
28 lines (25 loc) · 811 Bytes
/
auto.cpp
File metadata and controls
28 lines (25 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//
// Created by zing on 6/29/2020.
//
#include <iostream>
struct s{
int id;
}S;
auto main() -> int {
std::cout << "[auto.cpp]" << std::endl;
// Creating several auto-type variables
auto a = 1;
auto b = 1.0;
auto c = a + b;
auto d = {b, c};
auto e = "";
auto f = S;
// Displaying the preceding variables' type
std::cout << "type of a: " << typeid(a).name() << std::endl; //i
std::cout << "type of b: " << typeid(b).name() << std::endl; //d
std::cout << "type of c: " << typeid(c).name() << std::endl; //d
std::cout << "type of d: " << typeid(d).name() << std::endl; // St16initializer_listIdE
std::cout << "type of d: " << typeid(e).name() << std::endl; // PKc
std::cout << "type of d: " << typeid(f).name() << std::endl; // 1s
return 0;
}