C++
懒懒的小蜜蜂
这个作者很懒,什么都没留下…
展开
-
自己实现vector(C++)
#ifndef MVECTOR_H#define MVECTOR_H#include<iostream>#include"vector_iterator.h"using namespace std;template<typename T>class Mvector{public: typedef Vector_Iterator<Mvector<T>> iterator; Mvector(T* arr, int len) { _len原创 2021-07-13 11:11:10 · 235 阅读 · 0 评论 -
对vector进行测试(C++)
#include<vector>#include<iostream>using namespace std;/*模板 ----- 忽略类型的 函数/类 模板会在使用的时候根据传入或者推导出来的类型自动进行模板实例化函数模板函数模板的实例化类模板类模板的实例化模板基础模拟vector智能指针*/int main(){ vector<vector<int>> arr; for (int i = 0;原创 2021-07-13 10:20:14 · 453 阅读 · 0 评论 -
5.string写实拷贝
哦哦哦哦哦哦原创 2021-06-09 11:12:06 · 97 阅读 · 0 评论 -
6.迭代器
迭代器:#ifndef MITERATOR_h#define MITERATOR_h//#include"mstring.h"class Mstring;class Miterator{private: Mstring* _p_mstr; int _sit;public: Miterator(Mstring* p_mstr,const int sit) //构造函数,通过参数来构造 { _p_mstr = p_mstr; _sit = sit; } Miterato原创 2021-06-08 21:21:35 · 61 阅读 · 0 评论 -
3.运算符的重载和大数运算
一.运算符的重载#include<iostream>using namespace std;class FuN{private: int _a; int _bi;public: FuN(int a, int b) { _a = a; _bi = b; } FuN(const FuN& src)//拷贝构造函数,如果不加引用,会构成死循环 { _a = src._a; _bi = src._bi; } void show() {原创 2021-06-08 21:20:58 · 191 阅读 · 1 评论 -
4.自己模拟实现一个string
main.cpp#include<iostream>#include<string>using namespace std;int main(){ string s1("aaa"); string s2("bbb"); string s3; s3 = s1; s3 = "ccc"; s3 = s1 + s2; s3 = s1 + "ddd"; s3 = "ddd" + s1; s3 += s1; if (s1 > s2) {} if (s1原创 2021-06-08 21:19:59 · 85 阅读 · 0 评论 -
2.单例模式
一.双向链表的增删改查node.h#ifndef NODE_H#define NODE_Hstruct Node{ int _data; Node* _next; Node* _pro; //形成一个双向链表};#endiflist.h#ifndef LIST_H //防止多次引用头文件,如果引用了直接跳到最后一行#define LIST_H#include"node.h"#include<iostream>using namespace std;cl原创 2021-06-08 15:24:54 · 62 阅读 · 0 评论