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 };

 

posted @ 2020-10-17 20:50  世界を変える御宅族  阅读(125)  评论(0编辑  收藏  举报