C++实例 MySTLString
2024-09-03 23:16:39
#include <iostream>
#include <cstring>
#include <string>
using namespace std; class MySTLString
{
public:
MySTLString();
MySTLString(int count, char ch);
MySTLString(const char* s);
const char& front() const;
const char& back() const;
int size() const; private:
char* data_;
}; MySTLString :: MySTLString() : data_(new char[1])
{
*data_ = '\0';
} MySTLString :: MySTLString(const char* s) : data_(new char[strlen(s) + 1])
{
strcpy(data_, s);
} const char& MySTLString::front() const
{
return data_[0];
} int MySTLString::size() const
{
return strlen(data_);
} int main(void)
{
MySTLString str("Hello");
cout << str.front() << endl;
cout << str.size()<<endl; return 0;
}
最新文章
- codeforces problem 140E New Year Garland
- Myth – 支持变量和数学函数的 CSS 预处理器
- python抓取网站URL小工具
- ACM/ICPC 之 并查集-食物链(POJ1182)
- DX使用texconv工具批处理dds格式图片
- JAVA多线程实现的四种方式
- 记一个PowerShell的方法调用 --ResolveWindowsPrincipal
- 周赛-Colored Sticks 分类: 比赛 2015-08-02 09:33 7人阅读 评论(0) 收藏
- 【Reporting Services 报表开发】— 矩阵的使用
- None
- 关闭Sql Assistant的自动智能命名别名的问题
- 使用WiX Toolset创建.NET程序发布Bootstrapper(安装策略管理)(二)——自定义安装
- Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
- 01. Overview Redis 关于Redis
- SQLI DUMB SERIES-20
- 初步了解three.js
- 论文阅读笔记二十五:Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition(SPPNet CVPR2014)
- python基础之从认识python到python的使用
- composer require 指定版本
- mysql 安装成功以及第一次安装成功初始化密码操作