![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
Legolas~
这个作者很懒,什么都没留下…
展开
-
c++实现选择排序
#include<iostream> using namespace std; template<class T> int getArrayLength(T& arr) { return sizeof(arr) / sizeof(arr[0]); } int main() { int a[]={ 32,18,20,58,10 }; int a_len = getArrayLength(a); int min, temp, index; for (int i =原创 2021-03-29 15:56:33 · 77 阅读 · 0 评论 -
C++的vector容器存放自定义数据类型操作实例
#include<iostream> #include<vector> using namespace std; class Student { public: string m_Name; int m_Age; Student(string name, int age) { m_Name = name; m_Age = age; } }; void te...原创 2020-03-31 17:14:54 · 1661 阅读 · 1 评论 -
C++通过容器vector遍历数组两种方式
#include<iostream> #include<vector> #include<algorithm> using namespace std; template<typename T> void printEle(T value) { cout << value << endl; } void test() { ...原创 2020-03-31 16:22:20 · 948 阅读 · 0 评论 -
c++运算符重载
1.“+”重载 类成员函数: #include<iostream> using namespace std; class Test { public: int length; int width; Test() { } Test(int l, int w) { length = l; width = w; } Test operator+(Test& ...原创 2020-03-22 19:16:59 · 130 阅读 · 0 评论 -
C++的浅拷贝与深拷贝
在类中,我们若不自定义拷贝构造函数,则编译器会自动生成默认拷贝构造函数。若在类中,有一个公有的指针类型的属性成员,我们通过类实例化第一个对象,然后通过默认拷贝构造函数利用第一个实例化对象的副本去创建第二个对象,当调用我们自定义的析构函数释放掉类中的指针类型的属性成员时编译器并不会顺利执行。 #include<iostream> using namespace std; class Pe...原创 2020-03-20 21:27:44 · 189 阅读 · 0 评论