c++
Running_pink
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
初识c++ 泛型 函数模板
#include<iostream> using namespace std; template<typename T>//声明一个模板告诉编译器后面紧更的代码 T 是一种 通用的数据类型。不要报错 void test(T &a,T &b) { int temp; temp =a; a=b; b=temp; } int main(void) { int a=1,b=2; //1.自动类型推导 test(a,b); cout<<"a=原创 2021-09-20 22:58:33 · 168 阅读 · 0 评论 -
c++ 初识多态(一)
polymorphism.cpp #include <iostream> using namespace std; /* *多态:1.有继承关系 2.子类重写父类的虚函数 * *父类的指针 或者 引用 指向子类对象 * */ class animal{ public: virtual void speak()//底层用的函数指针实现虚函数 运行时指向子类的方法 { cout<<"animal is speaking"<<endl; } }; class cat原创 2021-09-04 22:07:31 · 188 阅读 · 0 评论 -
初识 c++ 构造函数 拷贝函数 析构函数
#include<iostream> #include<string> using namespace std; class Student{ public: Student()//类实例化时使用 { cout<<"无参构造函数调用"<<endl; } Student(string name,int id,int sex) { cout<<"有参构造函数调用"<<endl; this->n原创 2021-08-22 10:32:36 · 178 阅读 · 0 评论
分享