• 2024-08-22移情别恋c++ ദ്ദി˶ー̀֊ー́ ) ——6.vector(模拟实现)
    1.存储结构namespacezone{ template<classT>//需要模板 classvector { public:private: iterator_start; iterator_finish; iterator_endofstorage;};}可见,vector内核是由三个指针实现的2.默认成员函数 2.1.构造函数1.初始化列
  • 2024-08-09移情别恋c++ ദ്ദി˶ー̀֊ー́ ) ——4.模板
    1.泛型编程如何实现一个通用的交换函数呢?voidSwap(int&left,int&right){inttemp=left;left=right;right=temp;}voidSwap(double&left,double&right){doubletemp=left;left=right;right=temp;}voidSwap(char&left,char&right)
  • 2024-08-01移情别恋c++ ദ്ദി˶ー̀֊ー́ ) ——1.c++入门(2)
    1.函数重载C++⽀持在同⼀作⽤域中出现同名函数,但是要求这些同名函数的形参不同,可以是参数个数不同或者类型不同。这样C++函数调⽤就表现出了多态⾏为,使⽤更灵活。C语⾔是不⽀持同⼀作⽤域中出现同名函数的。#include<iostream>usingnamespacestd;//1、参数类型不同