Skip to content

Instantly share code, notes, and snippets.

@fabiogaluppo
Created January 25, 2016 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiogaluppo/9223837880fbe0c777c5 to your computer and use it in GitHub Desktop.
Save fabiogaluppo/9223837880fbe0c777c5 to your computer and use it in GitHub Desktop.
//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