- 博客(23)
- 收藏
- 关注
原创 C++学习笔记|模版
#include <iostream>#include <string>template <typename T>void function(T value){ std::cout<< sizeof(value)<<std::endl;}int main(){ int a=10; char b='a'; std::string c="test"; int*d=&a; functi.
2021-07-30 11:07:50
81
原创 C++学习笔记|运算符重载
#include <iostream>class Position{ int x,y;public: Position(int i,int j){ x=i; y=j; } void display(){ std::cout<<"("<<x<<","<<y<<")"<<std::endl; } //对运算符的重载实际上就是对函.
2021-07-30 09:29:52
77
原创 C++学习笔记|内联函数
一个类的所有对象不能共享内联函数的代码http://c.biancheng.net/view/199.html内联函数inline:1.在内联函数内不允许使用循环语句和开关语句; 2.内联函数的定义必须出现在内联函数第一次调用之前;只是声明不可以 3.类结构中所在的类说明内部定义的函数是内联函数。类中的内联函数??这块之后再补充...
2021-07-23 17:20:34
115
原创 C++学习笔记|子对象(构造函数和析构函数调用次序)
关心各个对象构造函数,析构函数执行的次序与在类中声明的次序有关,跟initializer list中的次序无关以在类B中说明的顺序调用子对象的构造函数,然后才是B的构造函数先是B的析构函数 然后以B中说明的相反次序调用子对象的析构函数#include <iostream>class A{ int m_a;public: A(){ m_a=1; std::cout<<"A constructor working...
2021-07-23 16:23:30
391
原创 C++学习笔记|类成员指针
类成员指针包括 类数据成员指针和类成员函数指针类数据成员指针#include <iostream>class Entity{public: Entity():m(0),n(0){} void dis(){ std::cout<<"m="<<m<<",n="<<n<<std::endl; } int m,n;};int main(){ int Entity::*p=
2021-07-23 15:39:28
54
原创 C++学习笔记|成员初始化表initializer list|Cherno C++ Tutorials
#include <iostream>#include <string>class Entity{private: std::string m_name; int m_score;public: Entity():m_name("Unknown"),m_score(0){// m_name="unknown"; } Entity(const std::string&name):m_name(name){// .
2021-07-22 14:55:46
58
原创 C++学习笔记|Const常量|Cherno C++ Tutorials
https://www.bilibili.com/video/BV1VJ411M7WR?p=34const在class中的应用常量指针 指针常量常量引用#include <iostream>//const在类中的应用class Entity{private: int m_x,m_y; mutable int m_z;//即使在const的成员函数中 仍然可以修改public: int test; int GetX() const //这.
2021-07-21 21:56:35
97
原创 C++学习笔记|命名空间namespace
解决了不同文件中 定义相同名字的不同函数之类的问题?在一个命名空间中定义的全局标识符 其作用域为该命名空间当在一个命名空间外部需要使用该命名空间中定义的全局标识符时 需要使用该命名空间的名字和域解析符来修饰main.cpp好像函数的声明之类的 也要放在命名空间里#include <iostream>namespace A{ extern int s;//这里的extern我还是不太懂 但是如果不加的话 linker报错 重复命名 void test();.
2021-07-21 15:35:23
60
原创 C++学习笔记|String|Cherno C++ Tutorials
String是一个类 它本质还是一个字符数组关于string的各种函数 内部实现 操作符重载 之后再补充#include <iostream>#include <string>int main(){ const char*name="test";//在内存中 默认字符串后面有一个\0中止 这样才知道字符串在哪里结束 char name2[6]={'a','b','c','d','e','\0'};//自己定义字符串数组的时候 要在最后加上\0 否则输出.
2021-07-21 15:16:21
77
原创 C++学习笔记|Array|Cherno C++ Tutorials
用new创建的数组 在堆上 需要使用delete释放#include <iostream>int* test(){ int *testArr=new int[5]; for (int i = 0; i < 5; ++i) { testArr[i]=i; } return testArr;}int main(){ int arr[5];//created on the stack int *ptr=new int.
2021-07-21 14:13:25
69
原创 C++学习笔记|Visibility|Cherno C++ Tutorials
private:本类和友元protected:本类 友元和子类public:不受限制 程序中的任何地方都可以访问
2021-07-21 11:23:18
117
原创 数据结构|插入排序
//// Created by Mitchell Liu on 7/19/21.//#include <stdio.h>//从小到大排序void InsertSort(int *arr,int n){ int temp; int i,j; for (i = 1; i < n; i++) { if(arr[i]<arr[i-1]){ temp=arr[i]; for (j = i-1; .
2021-07-19 09:58:14
52
原创 C++学习笔记|Virtual Function虚函数|Cherno C++ Tutorials
https://www.bilibili.com/video/BV1VJ411M7WR?p=28#include <iostream>class Parent{public: virtual std::string getName(){ return "Parent"; }};class Child:public Parent{private: std::string m_name;public: Child(const st
2021-07-16 10:25:51
83
原创 C++学习笔记|Inheritance|Cherno C++ Tutorials
派生类包含了基类的所有内容#include <iostream>class Parent{public: float x,y; Parent(){ x=0;y=0; } void print(){ std::cout<<x<<","<<y<<std::endl; }};class Son:public Parent{//这里的public是继承方式 可以是publ
2021-07-16 09:25:43
94
原创 C++学习笔记|Enum枚举类型|Cherno C++ Tutorials
#include <iostream>class Log{public: enum Level{ Error=0,Warning,Info };private: Level m_level=Info;//the prefix indicates member variable so you can differentiate it from local variablespublic: void Error_msg(const char .
2021-07-15 20:59:17
101
原创 C++学习笔记|Static in C++|Cherno C++ Tutorials
https://www.bilibili.com/video/BV1VJ411M7WR?p=21Static variables or functions outside of Struct or Class (only in current translation unit?)static的变量和函数只对当前文件可见 不使用static不同文件如果同名会报错 全局变量 可以被所有文件使用You can't have two global variables with the same name
2021-07-15 16:27:33
89
原创 C++学习笔记|Log类|Cherno C++ Tutorials
Log类https://www.bilibili.com/video/BV1VJ411M7WR?p=20The Log class is for debugging purposes.The Console is something built into the operating system so it will always work.The code may need to be improved in future videos.#include <iostream>.
2021-07-14 21:08:34
195
原创 模板引擎 atr-template
emmm其实没怎么看懂 要去看看官方文档?在浏览器中的使用在浏览器和服务器端都可以使用首先需要安装在node中使用https://www.bilibili.com/video/av27670326/?p=25客户端和服务器端模板引擎的区别...
2019-09-14 12:31:10
381
原创 基本的命令行指令
dir //输出当前目录cd 目录名 //打开目录cd . //打开当前目录cd .. //打开上一级目录md 文件夹名 //创建文件夹rd 文件夹名 //删除文件夹hello.txt //直接输入名字 打开txt文件d: //进入D盘环境变量在path变量中添加你想打开的文件的路径后便可在任意位置打开该文件...
2019-09-11 17:11:25
117
原创 JavaScript数据结构-栈
利用数组封装栈 同时使用栈来构造将十进制转换成二级制的函数<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title>栈的封装</title> <script> function Stack(){ this.item...
2019-09-11 14:10:40
63
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人