string
1 #pragma once 2 #include <initializer_list> 3 struct String { 4 String(const char*s) { 5 c_str = new char[strlen(s)+1]; 6 while (*s) { 7 *(c_str+sz) = *s++; 8 sz++; 9 } 10 *(c_str + sz) = '\0'; 11 } 12 ~String() { delete c_str; } 13 size_t size() { return sz; } 14 const char charAt(){} 15 private: 16 size_t sz = 0; 17 char* c_str; 18 };
所望隔山海