上一页 1 2 3 4 5 6 ··· 33 下一页
摘要: c++/oop 类模板 定义出一批相似的类, 可以定义类模板, 然后由类模板生成不同的类 例:可变长整型数组 写法: template <类型参数表(class 类型参数1,class 类型参数2...)> class 模板名{ .... }; 类模板中的成员函数在外面定义时: template < 阅读全文
posted @ 2022-03-31 15:24 liankewei123456 阅读(52) 评论(0) 推荐(0) 编辑
摘要: c++/oop 模板 函数模板 举例:swap template <class c1,class c2 , ...> 返回值类型 模板名(形参表){ } template<class T> void swap (T & x, T & y){ T tmp=x;x=y;y=tmp; } 编译器在编译的时 阅读全文
posted @ 2022-03-26 16:40 liankewei123456 阅读(74) 评论(0) 推荐(0) 编辑
摘要: c++/oop 文件操作 #include <fstream> 文件的打开和关闭: void open (const char * szFileName,int mode) 第一个参数是指向文件名的指针,第二个是文件打开模式标记 模式标记 ios::in (ifstream/fstream)打开文件 阅读全文
posted @ 2022-03-25 21:22 liankewei123456 阅读(49) 评论(0) 推荐(0) 编辑
摘要: AI引论 机器学习 监督学习 在已知输入和输出的情况下, 通过训练建立起输入到输出的映射模型应用最广的机器学习方法, 可进一步分为分类(结果离散)和回归(结果连续)两类算法 K-临近 给定一个待分样本(数据), 在训练集中查找离它最近的前 k 个邻居根据这些邻居的类别来给该样本的候选类别进行评分, 阅读全文
posted @ 2022-03-22 20:28 liankewei123456 阅读(40) 评论(0) 推荐(0) 编辑
摘要: #include <cstdio> #include <iostream> #include <cstdlib> #include <cstring> #include <algorithm> #include <cmath> #include <iomanip> #include <string> 阅读全文
posted @ 2022-03-21 11:42 liankewei123456 阅读(52) 评论(0) 推荐(0) 编辑
摘要: c++/oop 虚函数与多态的应用 在写大程序的时候,比如魔兽 可以先定义基类: Creature 然后再定义基类的n个派生类: Lion Wolf Iceman 如果这些派生类之间可以互相作用:战斗等 那么每一个派生类有与其他n-1个派生类的战斗函数,很复杂 使用多态的时候,只需要再基类里面实现 阅读全文
posted @ 2022-03-19 17:16 liankewei123456 阅读(31) 评论(0) 推荐(0) 编辑
摘要: c++/oop 虚函数和多态 虚函数 定义: class Base{ virtual int get(); }; int Base:: get(){ } 派生类的地址可以赋给基类指针。通过基类指针调用基类和派生类中的同名同参虚函数时:若该指针指向一个基类的对象,那么被调用是基类的虚函数;若该指针指向 阅读全文
posted @ 2022-03-17 11:27 liankewei123456 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 查看代码 #include <cstdio> #include <iostream> #include <cstdlib> #include <cstring> #include <algorithm> #include <cmath> #define db double #define inf 1 阅读全文
posted @ 2022-03-15 10:51 liankewei123456 阅读(15) 评论(0) 推荐(0) 编辑
摘要: string 用法 string 变量名 string city = "Beijing" 一个 string 对象的大小是固定的,与字符串的长短无关,只保存地址和一些其他信息。 string as[] = {"asd","dfg","ertw"}; cout<<as[1]<<endl; string 阅读全文
posted @ 2022-03-13 22:28 liankewei123456 阅读(106) 评论(0) 推荐(0) 编辑
摘要: c++/oop 继承与派生 继承:在定义一个新的类 B 时,如果该类与某个已有的类 A 相似 (指的是 B 拥有 A 的全部特点), 那么就可以把 A 作为一个基类,而把 B 作为基类的一个派生类 (也称子类)。 逻辑:B对象也是一个A对象 例 : 查看代码 #include <cstdlib> # 阅读全文
posted @ 2022-03-12 16:18 liankewei123456 阅读(64) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 33 下一页