Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
//type declaration
int x = 2;
double e = 2.71828;
std::string s = "Simply C++";
std::cout << x << " -> "<< typeid(x).name() << "\n"; //2 -> int
std::cout << e << " -> "<< typeid(e).name() << "\n"; //2.71828 -> double
std::cout << s << " -> "<< typeid(s).name() << "\n"; //Simply C++ -> class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
//type deduction
auto x_ = x;
auto e_ = e;
auto s_ = s;
std::cout << x_ << " -> "<< typeid(x_).name() << "\n"; //2 -> int
std::cout << e_ << " -> "<< typeid(e_).name() << "\n"; //2.71828 -> double
std::cout << s_ << " -> "<< typeid(s_).name() << "\n"; //Simply C++ -> class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment