[姆咪] Modern C++

作者: nh60211as   2021-07-07 08:30:37
Me: can we have modern C++?
Mom: we have modern C++ at home
Modern C++ at home:
1. const std::string str = "Modern C++";
2. std::string s1 {"Modern C++", 3};
3. std::string s2 {str, 3};
4.
5. std::cout << "S1: " << s1 << "\n";
6. std::cout << "S2: " << s2 << "\n";
Output:
S1: Mod
S2: ern C++
資料來源:
https://twitter.com/vzverovich/status/1345776339014488064
https://en.cppreference.com/w/cpp/string/basic_string/basic_string
s1 是用 (3) 建構式
basic_string( const basic_string& other,
size_type pos,
size_type count = std::basic_string::npos,
const Allocator& alloc = Allocator() );
s2 是用 (4) 建構式
basic_string( const CharT* s,
size_type count,
const Allocator& alloc = Allocator() );
作者: ILoveElsa (S級18位 梓喵醬油瓶)   2021-07-07 08:32:00
看成莫德納
作者: lturtsamuel (港都都教授)   2021-07-07 09:23:00
垃圾西甲甲

Links booklink

Contact Us: admin [ a t ] ucptt.com