1、实现一种自己喜欢但C++不支持的数据类型——变长字符串类型。所谓变长字符串,即根据需要的大小分配字符动态数组空间。重载该类型的常用运算符,比如字符串赋值(=)、比较(>或<)、连接(+)、插入(<<)、提取(>>)等。注意内存的分配与回收,注意构造函数、复制构造函数和析构函数的使用。
2、使用自己定义的变长字符串类型,实现一个有意义的程序。
3、自学读写文件操作完成自动存盘等。
#include <cstddef>
class foo
{
public:
constexpr foo() noexcept;
constexpr foo( const char* s );
constexpr foo( const foo& other );
constexpr foo( foo&& other ) noexcept;
constexpr foo( std::nullptr_t ) = delete;
~foo();
constexpr foo& operator=( const char* s );
constexpr foo& operator=( const foo& other );
constexpr foo& operator=( foo&& other ) noexcept;
constexpr foo& operator=( std::nullptr_t ) = delete;
constexpr foo& assign(