上一页 1 2 3 4 5 6 ··· 61 下一页
摘要: C与C++在函数和数据的比较 C Data(struct) 数据是一个类型 -> 根据数据的类型创建出真正的数据 Function 函数就是用来处理数据的 缺陷: 语言没提供关键字.所以数据是全局的 -> 各个函数都可以处理数据 C++ Data 将数据和处理这些数据的函数包裹在一起,其他函数看不到 阅读全文
posted @ 2024-04-13 18:54 俊king 阅读(1) 评论(0) 推荐(0) 编辑
摘要: Veriadic templates 数量不定的模板参数 声明方式: #pragma once#ifndef __VARIADICT__#define __VARIADICT__​/*为什么需要定义这个空函数,因为传参到最后传入最后一位参数时后面的一组参数已经没有了.就是0所以这个版本就是没有参数的 阅读全文
posted @ 2024-04-13 18:53 俊king 阅读(1) 评论(0) 推荐(0) 编辑
摘要: namespace 测试程序使用namespace包裹 示例代码: #include <iostream>#include <memory>#include <list>namespace jj01{ void test_member_template() {}}​namespace jj02{ t 阅读全文
posted @ 2024-04-13 18:52 俊king 阅读(1) 评论(0) 推荐(0) 编辑
摘要: Pointer-like classes像指针又像函数 智能指针概念: 一个类做出来像类又像指针 示例代码: #pragma once#ifndef __SHAREPOINTER__#define __SHAREPOINTER__​template<class T>class shared_ptr{ 阅读全文
posted @ 2024-03-31 13:27 俊king 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 泛型编程(Generic Programming) 虚函数 -> 含有虚函数的类就是抽象类 编译(compile) 链接(link) 转换函数(Conversion function) 例如将小数转成分数,就是一个转换函数 #pragma once#ifndef __FRACTION__#defin 阅读全文
posted @ 2024-03-31 13:24 俊king 阅读(3) 评论(0) 推荐(0) 编辑
摘要: Composite设计模式 虚函数 继承与父类.又可以携带指针(Delegation) 示例代码: component.h -> 统一父类 #pragma once#ifndef __COMPONENT__#define __COMPONENT__​class Component{ int valu 阅读全文
posted @ 2024-03-31 13:00 俊king 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 类和类之间的关系 Object Oriented Programming Object Oriented Design 面向对象的思想:类与类之间产生关系 关系: Inheritance -> 继承 Composition -> 复合 Delegation -> 委托 -> Composition 阅读全文
posted @ 2024-03-30 15:31 俊king 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 类模板、函数模板、其他 static 示例代码: #ifndef __COMPLEX__#define __COMPLEX__​class complex{ // 成员函数的隐藏参数有this -> 形参不能写.返回值当中可以写可以不写 public: double real() const { r 阅读全文
posted @ 2024-03-30 15:29 俊king 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 类定义(class definition) class以外的函数 存在的一定是函数 如果是class的函数,那么一定带有类名::function 要么就是全局函数,函数名称不会带有class_name_function_name 非成员函数(无this) 示例代码: inline complexop 阅读全文
posted @ 2024-03-30 01:31 俊king 阅读(3) 评论(0) 推荐(0) 编辑
摘要: Class with pointer member(s) -> 带指针的类 String字符串为讲解对象 设计一个Class先设计头文件 示例代码: #pragma once​// 防卫式声明#ifndef __STRING__#define __STRING__​#include <string. 阅读全文
posted @ 2024-03-28 19:24 俊king 阅读(1) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 61 下一页