自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(70)
  • 收藏
  • 关注

原创 多继承与虚基类

多继承多继承中的二义性问题虚基类虚基类的构造函数

2021-01-22 10:23:21 190

原创 C++(OOP)命名空间

命名空间的定义每个命名空间是一个作用域命名空间可以是不连续的接口和现实的分离嵌套命名空间命名空间成员的使用using std::vector;using primer = cplusplus_primer;using namespace std;

2021-01-20 17:25:04 187 2

原创 C++(OOP)标准异常

exceptionruntime_errorrang_erroroverflow_errorunderflow_errorlogic_errordomain_errorinvalid_argumentlength_errorout_of_range

2021-01-20 15:45:24 173

原创 C++(OPP)异常层次结构

异常层次结构异常是类 可以自己创建异常派生异常中的数据:数据成员按引用传递异常在异常中使用虚函数

2021-01-19 16:32:47 196

原创 Python少儿编程 第一讲 知识点总结

什么是编程语言编程语言是计算机和人沟通的语言,我们和美国人交流用英语,我们和计算机交流就要用编程语言计算机的编程语言有很多种:C/C++、Java、Python使用编程语言的时候要把输入法切换成英文输入法shift键可以切换中英文输入法Python的编程方式交互式编程文件式编程Print函数的使用print("要输出的内容")print 的中文是打印 就是把内容呈现在屏幕上注释的使用作用:增加文件的可读性注释分为单行注释和多行注释# 这是一个单行注释"""这

2021-01-16 16:38:29 583

原创 C++(OOP)异常

传统处理方法C++处理异常方法trycatchthrow异常类型数字字符串类对象#include <stdio.h>#include <iostream>using namespace std;class BadSrcFile{};class BadDestFile{};class BadCopy{};int my_cp(const char * src_file, const char * dest_file){ FILE *.

2021-01-15 22:13:01 2606 5

原创 C++(OOP)函数模板

函数模板 → 实例化 → 函数模板形参四个例子

2021-01-15 21:09:09 503

原创 C++(OOP)模板与泛型编程

两种模板类模板、函数模板泛型编程主要用于容器、迭代器、算法 -> C++ STL 标准模板库示例1.普通队列2.C++中的泛型容器:vector、list、set 等等3.顺序队列4.链式队列

2021-01-14 17:03:27 241

原创 C++(OOP)纯虚函数与抽象类

纯虚函数与抽象类虚函数抽象类 抽象数据类型任何包含一个或多个纯虚函数的类都是抽象类不要创建这个类的对象,应该继承它务必覆盖从这个类继承的纯虚函数实现纯虚函数C++接口只包含纯虚函数的抽象基类...

2021-01-13 10:53:03 137

原创 C++(OOP)静态成员与继承

基类中的static成员,在整个继承层次中只有一个实例在派生类中访问static成员的方法基类名::成员名子类名::成员名对象.成员名指针->成员名成员名

2021-01-12 09:12:58 207

原创 C++(OOP)友元与继承

1

2021-01-12 08:53:58 215

原创 C++(OOP)派生类构造函数和析构函数

#include <iostream>using namespace std;class Base{public: Base() { b1 = b2 = 0; } Base(int i, int j); ~Base(); void Print() { cout << b1 << ", " << b2 << ", "; }private: int b1, b2;};Base::Base(int i, int

2021-01-10 19:00:42 170

原创 计算机网络:HTTP相关知识点

计算机网络HTTP定义、特性、性能定义定义:HTTP叫做超文本传输协议功能:两点间的数据传递 PS:不止是服务器与客户端之间的通信,还可以是服务器与服务器之间的通信特性(优缺点)优点:简单、易于扩展、跨平台1.简单:基本报文格式是:header+body,头部信息是键值对形式2.易于扩展:HTTP协议规则没有固定死,允许开发人员自定义和扩充3.跨平台:HTTP具有天然的跨平台特性,从PC的上的浏览器到智能手机上的APP都有用到双刃剑:无状态、明文传输1.无状态:优点:不需要额外

2021-01-10 09:08:40 312

原创 C++(OOP)三种继承

三种继承公有、私有、受保护继承class B : public Aclass B : private Aclass B : protected A修改继承访问using A::a1

2021-01-04 11:45:57 105

原创 C++(OOP)动态绑定

动态绑定多态从派生类到基类的转换只有通过引用或指针调用虚函数才会发送动态绑定引用或指针既可以指向基类对象,也可以指向派生类对象

2021-01-04 10:40:34 132 1

原创 C++(OOP):定义基类和派生类

#include <iostream>using namespace std;// 基类class Animal{ // 成员略};// 继承 or 派生class Dog: public Animal{ // 成员略};// 继承 or 派生class Cat: public Animal{ // 成员略};int main(){ Animal A; Dog B; Cat C; return 0;}#include <i

2021-01-03 15:12:12 371

原创 C++(OOP):转换类型操作符

转换类型操作符必须是成员函数不能是指定返回类型形参表必须是空必须显示的返回一个指定类型的值不应该改变被转换对象,通常定义为const#include <iostream>#include <string>using namespace std;class Dog{public: Dog(string n, int a, double w):name(n),age(a),weight(w){} // 转换操作符 // 必须是成员函数 // 不能

2021-01-03 14:10:44 113

原创 常用文件IO函数

open函数#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>​int open(const char *pathname, int flags);int open(const char *pathname, int flags, mode_t mode);功能: 打开文件,如果文件不存在则可以选择创建。参数: pathname:文件的路径及文件名 flags:

2021-01-02 08:36:38 289

原创 C语言错误处理函数的使用方法

错误处理函数的使用方法errno 是记录系统的最后一次错误代码。代码是一个int型的值,在errno.h中定义。当Linux C api函数发生异常时,一般会将errno全局变量赋一个整数值,不同的值表示不同的含义,可以通过查看该值推测出错的原因#include <stdio.h> //fopen#include <errno.h> //errno#include <string.h> //strerror(errno)​int main(){

2021-01-02 08:23:36 585

原创 C++(OOP)重载操作符

重载操作符的定义#include <iostream>using namespace std;class Person{ // 重载操作符: 加法public: // 重载函数必须重载 类类型 // 定义重载操作符 void operator+(const Person& lhs) { cout << "执行了重载的加法操作" << endl; } // 最好不要重载 && || & *++(OOP)}

2020-12-28 15:37:02 148

原创 C++(OOP)深复制、浅复制

案例#include <iostream>#include <string.h>using namespace std;class Demo{public: Demo(int pa, char *cstr) { this->a = pa; this->str = new char[1024]; strcpy(this->str, cstr); }public: int a; char *str;};int main().

2020-12-24 16:30:06 122 2

原创 基数排序(C++实现)

基数排序#include <iostream>#include <list>using namespace std;int maxdigit(int data[], int n){ int d = 1; // 计位器: 1 1位数 2 两位数 int p = 10; // 倍数 // 求数组中最高位的的位数 for (int i = 0; i < n; ++i) { while (data[i] >= p) { p *= 10;

2020-12-24 08:59:24 1751

原创 C++(OOP)析构函数

析构函数构造函数用来创造资源,析构函数用来释放资源没有自定义析构函数,C++自动创建析构函数,但创建的析构函数功能有限调用过程#include <iostream>#include <string>using namespace std;class NoName{public: // 构造函数 NoName():pstring(new std::string),i(0),d(0){ cout << "构造函数被调用了" <<

2020-12-23 16:21:44 87 1

原创 C++(OOP)复制构造函数和赋值操作符

赋值构造函数如果没有定义,C++会给我们定义使用自定义构造函数的情况: 类成员中存在指针赋值操作符如果没有定义,C++会给我们定义使用自定义赋值操作符的情况: 类成员中存在指针#include <iostream>#include <string>#include <vector>using namespace std;class Sales_item{public: // 公有成员 // 构造函数 Sales_item():un

2020-12-23 11:48:12 107

原创 链式队列(C++实现)

/* LinkQueue.h */#ifndef LINKQUEUE_H_#define LINKQUEUE_H_template<class T>class Queue{public: Queue(); ~Queue(); bool isEmpty() const; const T & getFront() const; // 查看队头 void enqueue(const T & x); // 入队 T dequeue(); // 出队 voi

2020-12-21 15:33:33 333

原创 C++(OOP)static 类成员

static 类成员的优点static 静态类成员定义以后所有这个类的对象都能使用,比全局变量安全,比私有成员方便易用管理#include <iostream>#include <string>using namespace std;class Account {public: Account(std::string name, double money): owner(name),amount(money){} double getAmount() c

2020-12-21 14:47:28 132

原创 Makefile使用指南速查

简介Makefile可以方便我们解决多文件编译的问题Makefile命名规则makefile和Makefile都可以使用,推荐使用Makefile语法规则规则目标:依赖文件列表命令列表test: echo "hello world"命名格式make是一个命令工具,它解释Makefile 中的指令(应该说是规则)。make命令格式:make [ -f file ][ options ][ targets ]1.[ -f file ]:make默认在工作目录中寻找名为GN

2020-12-18 10:27:27 312

原创 链栈(C++实现)

/* LinkStack.h */#ifndef LINKSTACK_H#define LINKSTACK_Htemplate<class T> class LinkStack;template<class T>class ChainNode{public: friend class LinkStack<T>;private: ChainNode(const T& theData, ChainNode *n = 0):data(theDat

2020-12-17 17:23:42 225

原创 C++(OOP)友元

类的友元函数普通函数无法使用类的私有成员友元函数可以使用类的私有成员#include <iostream>#include <string>using namespace std;class Person{public: Person(int ag, std::string nm):name(nm),age(ag){}; /* 定义友元函数 */ /* 友元函数可以调用类的私有变量 */ friend int getAge(Person &);p

2020-12-17 16:12:05 117

原创 GDB调试工具命令速查

1.生成调试信息一般来说GDB主要调试的是C/C++的程序。要调试C/C++的程序,首先在编译时,我们必须要把调试信息加到可执行文件中。使用编译(gcc/g++)的 -g 参数可以做到这一点$ gcc -g test.c$ g++ -g test.cpp如果没有-g,你将看不见程序的函数名、变量名,所代替的全是运行时的内存地址。2.启动GDB启动gdb$ gdb program(program 也就是你的执行文件,一般在当前目录下)设置运行参数(gdb) set ar

2020-12-16 19:40:18 300

原创 C++(OOP)构造函数

设计一个类的时候必须写上一个构造函数#include <iostream>#include <string>using namespace std;class Person{public: /* 设计一个类的时候必须写上一个构造函数 */ Person(const std::string &nm, int a):name(nm),age(a){}private: std::string name; int age;};int main(){

2020-12-15 13:32:11 129

原创 看完这篇文章学会GCC不是梦

gcc编译器从拿到一个c源文件到生成一个可执行文件,中间一共经历了4个步骤:四个步骤并不是gcc独立完成的,而是在内部调用了其他工具,从而完成了整个工作流程:gcc工作流程:// 定义一个c源文件#include <stdio.h>int main(){ printf("hello world\n"); return 0;}$ gcc -E hello.c -o hello.i # 预处理$ gcc -S hello.i -o hello.s # 生成汇编文件$ g

2020-12-13 11:42:12 74

原创 C++(OOP)类的作用域

类的作用域#include <iostream>using namespace std;class First{public: /* 一般情况下数据成员不要写在public里面 */ /* 这里是为了举例子 */ int number; void doA() { number = 22; }};int main(){ /* number的作用域是在类内 */ //number = 11; // ERROR! First obj; obj.nu

2020-12-13 11:19:09 113

原创 C++(OOP)隐含的this指针

this指针的用法:在类中使用this可以让代码更加清晰易读#include <iostream>#include <string>using namespace std;/* 定义一个Person类 */class Person{public: Person(const std::string &name, const std::string address) { /* this指代当前对象 可以省略 */ /* 如果写上的话代码看起来更加清

2020-12-12 13:47:40 102

原创 C++(OOP)类定义详解(3)

#include <iostream>#include <string>using namespace std;class Screen; // 只是类声明 class LinkScreen{ Screen *window; LinkScreen *next; LinkScreen *prev;};class Y;class X{ // 各种成员忽略private: Y *ptr;};class Y{ // 各种成员略private:

2020-12-11 09:14:07 104

原创 C++(OOP)类定义详解(2)

类里面可以 - 定义成员函数类里面可以 - 使用别名简化#include <iostream>#include <string>using namespace std;/* 定义一个Screen类 */class Screen{public: /* 类中可以使用别名 作用域是整个类 */ typedef std::string::size_type index; Screen (index ht = 0, index wd = 0):contents(ht *

2020-12-10 11:29:50 99

原创 C++(OOP)类定义详解(1)

1

2020-12-10 10:27:34 153

原创 C++详解(7) 字符串流

基本使用#include <iostream>#include <sstream>#include <string>using namespace std;int main(){ // 字符串流是在内存内进行操作 ostringstream oss; // 定义一个字符串输入流 oss << "hello world!" << endl; cout << oss.str() << endl;.

2020-12-08 15:44:06 347

原创 c++实践小函数经验积累(一)

读取文件输入并判断是否合法// get.cc# include "get.h"std::istream& get(std::istream& in){ int ival; // 类型可以替换 可以修改成模板函数 while(in >> ival, !in.eof()) { if (in.bad()) throw std::runtime_error("IO stream corrupted"); if (in.fail()) { st.

2020-12-07 23:27:17 122

原创 顺序队列(C++实现)

// Queue.h#ifndef _QUEUE_H#define _QUEUE_Htemplate<class T>class Queue{ public: Queue(int queueCapacity=10); bool IsEmpty() const; // 判空 T& Front() const; // 头索引 T& Rear() const; // 尾索引 void Push(const T& item);

2020-12-07 16:53:10 332

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除