自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 资源 (2)
  • 问答 (1)
  • 收藏
  • 关注

原创 友元函数

//友元函数:可以访问类的私有数据成员和私有函数。   友元函数声明有friend,但定义不需要。#include <iostream>#include <cstring>using namespace std;class persion{public: persion(char *pn); //友元函数; friend voi...

2018-05-18 16:18:24 964

原创 const和mutable

#pragma once#include <iostream>class constmutable{public: int a; int b; int c; const int d=0;//常量是必须存在初始化 mutable int e;//限定了不被const所限制public: void setabc(int a, int b, int c) { th...

2018-05-18 11:44:35 209

原创 内联函数

#pragma once //头文件 fushu.h#include <iostream>class fushu{public: int x; int y;public: fushu(); ~fushu(); void show(); inline void showall(int x, int y);//显式内联 void setxy(int ...

2018-05-18 11:08:01 313

原创 深拷贝与浅拷贝

#define _CRT_SECURE_NO_WARNINGS //两种构造函数#include <iostream>#include<string>class string{public: char *p; int length; string(int num,char *str) { //获取长度,分配内存,拷贝内容 length =...

2018-05-17 22:25:22 132

原创 类的构造函数与析构函数

类的构造函数与析构函数#include<iostream>//所有的类默认都有一个构造函数,析构函数//构造函数,重载,//没有返回值,class myclass{public:int num;public:myclass()// :num(4)初始化第一种方式{//num = 10;初始化第二种方式std::cout << "class create";}myclass...

2018-05-17 21:30:44 385

原创 去掉转义字符

#include <iostream>#include<string>#include<stdlib.h>void main(){ std::string path =R"( "E:\Program Files (x86)\Tencent\QQ\Bin\QQScLauncher.exe")"; //R"()" 括号之间去掉转义字符 sys..

2018-05-17 17:37:50 2464

原创

面向对象编程的程序基本单位是类。类是数据和操作数据的函数的封装。类的对象使用自己的方法完成对数据的操作。类可以隐藏数据和操作细节,对象通过类接口与外部通讯。...

2018-05-17 16:36:20 129

原创 静态断言

#include <stdio.h>#include<assert.h>#include<iostream>//断言:迅速找到using namespace std;#define N 10void main1(){ int num = 100; cout << num << endl; cout <&l...

2018-05-16 18:05:42 216

原创 C++多线程

C11中采用thread实现多线程#include <thread>#include<iostream>#include<windows.h>#include<vector>//join主要是让主线程等待直到子线程执行结束。using namespace std;using namespace std::this_thread;vo...

2018-05-16 17:40:52 145

原创 智能指针

#include <iostream>//智能指针:存储指向动态分配(堆)对象指针的类,用于生存期控制,能够确保自动正确的销毁动态分配的对象,防止内存泄露void main1(){ //auto_ptr; for (int i = 0; i < 10000000; i++) { double *p = new double;//为指针分配内存 std:...

2018-05-16 16:49:49 148

原创 模板元编程

模板元编程:游戏开发中实现递归,使得编译时期长,运行速度快。#include<iostream>//模板元吧运行时消耗的时间,在编译期间优化template<int N>struct data{ enum {res =data<N-1>::res+data<N-2>::res};};template<>struct d...

2018-05-15 09:58:42 184

原创 CPP别名 using

https://www.cnblogs.com/yutongqing/p/6794652.htmltypedef和using在定义别名时的区别template <typename T>typedef std::vector<T> v;//使用typedeftemplate <typename T>using v = std::vector<T&g...

2018-05-14 22:42:28 1422

原创 内部函数绑定 bind()

#include<iostream>#include<functional>//处理函数using namespace std;using namespace std::placeholders;//仿函数,创建一个函数指针,引用一个结构体内部或者一个类内部的公有函数struct MyStruct{ void add(int a) { cout &...

2018-05-14 22:07:32 309

原创 引用包装器

#include<iostream> template<class T>void com(T arg)//模板函数,引用无效,引用包装器{ std::cout <<"com ="<< &arg << "\n"; arg++;}void main(){ int count = 10; in

2018-05-14 21:38:06 144

原创 模板函数与普通函数的选择问题

#include <iostream>//函数模板可以对类型进行优化重载,根据类型会覆盖//如果仍然要使用模板函数,需要实例化template<class T>T add(T a,T b){ std::cout << " T add" << std::endl; return a + b;}//根据调用类型,优先选择普通函数i...

2018-05-14 11:51:14 203

原创 函数模板重载

#include<iostream>#include<array>using std::array;template<typename T>void showarray(array<T,10> myarray,int n){ using namespace std; cout << "TTTTT" <<

2018-05-14 11:42:53 126

原创 new的高级用法

#include<iostream>#include<new>const int buf(512);//限定一个常量整数512int N(5);//数组的长度char buffer[buf] = {0};//静态区//p1,p3,p5作为指针变量在栈区,存储的地址指向堆区 易发生内存泄漏//手动释放内存//p2,p4,p6作为指针变量在栈区,存储的地址在静...

2018-05-11 17:45:53 480

原创 可变长函数参数模板

#include <iostream>//通用可变参数模板 处理不限定个数的参数,处理不同类型void showall()//空函数,接口,最后结束递归 新版本编译 强制预留接口{}template<typename T,typename...Args> /// ...可变长度!!!!void showall(const T &am...

2018-05-11 16:32:43 228

原创 函数包装器

#include<iostream>#include<functional>//函数包装器//第一,设计执行接口,接口设计关卡(),计数//第二,函数包装器依赖于函数模板,实现通用泛型//第三,函数代码可以内嵌在另外一个函数,实现函数怀孕//函数包装器,用于管理内嵌函数,外部函数调用//函数包装器, T数据类型, F是函数template<...

2018-05-11 15:52:52 211

转载 QT中出现invalid use of incomplete type 'class-Ui-Widge't的解决办法

先说环境qt 5.5.1Windows7gcc version 4.8.1错误详情如下图: 原因及解决办法可以确定的是,你肯定在Qt Designer中修改了顶部Widget的object name,然而,Qt creator并不会帮你同步gotocell.cpp中的obj name。导致不对应,自然就报错了。 应该有两种方法: 1. 比较简单的方法,观察错误中的class Ui::gotoCel...

2018-05-09 11:15:00 12183 1

C 题库汇总 (1).xls

原创 静态断言 #include <stdio.h> #include<assert.h> #include<iostream> //断言:迅速找到 using namespace std; #define N 10 voi... 2018-05-16 18:05:42 阅读数 87 评论数 0 原创 C++多线程 C11中采用thread实现多线程#include <thread> #include<iostream> #include<windows.h> #include<vector> /... 2018-05-16 17:40:52 阅读数 35 评论数 0 原创 智能指针

2020-03-26

C 题库汇总.xls

leetcode 刷题 /*46.全排列给定一个没有重复数字的序列,返回其所有可能的全排列。回溯大法!!*/void dfs(vector<int>& nums, int curSize,vector<vector<int>>& res, vector<int> &vec, map<int, int>& visited){... 9次阅读2019-12-20 11:40:50 友元函数 //友元函数:可以访问类的私有数据成员和私有函数。 友元函数声明有friend,但定义不需要。#include <iostream>#include <cstring>using namespace std;class persion{public: persion(char *pn); //友元函数; friend voi... 736次阅读2018-05-18 16:18:24

2020-03-26

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

TA关注的人

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