
c++
wake_alone
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
const 和static知识点
关于C++ const 的全面总结关于C++ const 的全面总结c++-静态成员函数和非静态成员函数的区别关于C++ const 的全面总结转载 2018-05-29 12:51:22 · 191 阅读 · 0 评论 -
c/c++形参const字符串的更改方式
#include <iostream> using namespace std; void func(const char*& str) { str++; } void func1(const char** str) { (*str)++; } int main() { const char* str="adas"; cout<<str<&...原创 2018-08-08 15:47:24 · 405 阅读 · 0 评论 -
C++ inline函数的一点理解(参数传递和函数调用)
#include <iostream> using namespace std; static inline int func(int a,int b){ return a+b; } int func1(int a,int b){ return a+b; } int main () { int a=1; int b=2; int a1=1; int b1=2; ...原创 2018-07-27 14:05:08 · 1089 阅读 · 0 评论 -
C++ STL---set总结
自动排序 没有下标访问的方式 查找的返回值两个:first是地址--可以用it指向,second是bool是否成功 set和map的iterator除非删除这个迭代器指向的,否则迭代器不会失效,因为是指针指向的。 set的插入和搜索速度为log2 N #include <iostream> #include <set> using namespace std; ...原创 2018-07-26 16:54:31 · 190 阅读 · 0 评论 -
C++字符串分割
void SplitString(const std::string& s, std::vector<std::string>& v, const std::string& c) { std::string::size_type pos1, pos2; pos2 = s.find(c); pos1 = 0; while(std::string::npo...转载 2018-07-20 16:55:35 · 166 阅读 · 0 评论 -
【整理】C/C++中字符串与整数之间的相互转换
一、用C标准IO库中的sprintf()和sscanf()转换 sprintf()函数原型: #include <stdio.h> int sprintf(char *str,const char *format); 函数的功能是:将变量打印到字符串中。(与printf的用法一致,区别仅在于sprintf()打印到字符串,而printf()打印到标准输出) 因此可利用s...转载 2018-07-20 11:25:25 · 791 阅读 · 2 评论 -
C++基础:C++标准库之栈(stack)和队列(queue)
C++基础:C++标准库之栈(stack)和队列(queue)转载 2018-07-19 14:11:54 · 16310 阅读 · 0 评论 -
C++ STL---vector总结(四):二位数组
不用vector,动态申请和初始化。 int **dp=new int * [n]; for(int i=0;i<n;i++) dp[i]=new int[m]; for(int i=0;i<n;i++) memset(dp[i],0,sizeof(int)*m); 用Vector,一定要考虑清楚横纵的大小,提前设置好,否则会报错 具体设置方法如下: vec...原创 2018-07-19 10:01:44 · 313 阅读 · 0 评论 -
一篇文章看明白 C++ 虚函数表
看了鸡啄米的博客,感觉挺易懂的。 入门的就简单的介绍,如果是需要进行深入理解的,也有相应的测试博客,配合着书本来看很好。 我这里只贴一些代码,详细的建议看原博客。 一篇文章看明白 C++ 虚函数表 #include <iostream> using namespace std; class Base1 { public: virtual void f()...转载 2018-07-24 14:47:06 · 160 阅读 · 0 评论 -
C++入门--动态创建一维、二维数组
动态创建一维数组VS2010中输入:#include <iostream> using namespace std; //根据变量动态创建一维数组 int main() { int N=5; int *p=new int[N]; /*初始化方法一*/ //memset(p,0,sizeof(int)*N); /*初始化方法二*/ for(int i=0;i<N;i++...原创 2018-07-05 15:41:04 · 2749 阅读 · 0 评论 -
C++位运算,全排序,全组合
C++ STL 全排列函数详解 STL方法: #include <iostream> #include <algorithm> using namespace std; int main () { int arr[] = {3,2,1}; cout<<"用prev_permutation对3 2 1的全排列"<<endl; ...转载 2018-07-23 13:15:27 · 953 阅读 · 0 评论 -
leetcode105. 从前序与中序遍历序列构造二叉树Construct BinaryTree From Preorder And Inorder Traversal
根据一棵树的前序遍历与中序遍历构造二叉树。注意:你可以假设树中没有重复的元素。例如,给出前序遍历 preorder = [3,9,20,15,7] 中序遍历 inorder = [9,3,15,20,7]返回如下的二叉树: 3 / \ 9 20 / \ 15 7思路:前序第一个是根节点,然后根据中序的根节点位置,可以将树变成左右两棵子树。然后递归是否为空?ne...原创 2018-07-11 14:55:41 · 166 阅读 · 0 评论 -
C++ STL---map总结
#include <iostream> #include <map> #include <string> using namespace std; int main() { map <int,string> mymap; /*三种插入数据的方式*/ mymap.insert(pair<int,string> (1,"student...原创 2018-07-10 10:35:02 · 185 阅读 · 0 评论 -
C++笔试面试常考知识点汇总
C++笔试面试常考知识点汇总(一)C++笔试面试常考知识点汇总(二)C++笔试面试常考知识点汇总(三)C++笔试面试常考知识点汇总(四)转载 2018-07-09 15:49:49 · 3214 阅读 · 0 评论 -
struct和typedef struct彻底明白了
struct和typedef struct转载自: https://www.cnblogs.com/qyaizs/articles/2039101.html分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int a; }Stu; 于是在声明变量的时候就可:S...转载 2018-07-09 15:15:41 · 356 阅读 · 0 评论 -
C++ STL---vector总结(三):内存管理,排序,存放结构体,swap,shrink to fit
内存管理:使用reserve()提前设置容量大小#include <iostream> #include <vector> #include <algorithm>//find using namespace std; int main(){ /*memory management内存管理 1.size() 获得容器中元素个数 2.capacity()...原创 2018-07-09 14:26:12 · 858 阅读 · 0 评论 -
C++ STL---vector总结(二):增删查改
#include <iostream> #include <vector> #include <algorithm>//for_each using namespace std; int main(){ /*add element增加*/ /*add element method 1---push back从最后面插入*/ vector<int&g...原创 2018-07-09 12:26:10 · 1453 阅读 · 0 评论 -
C++ STL---vector总结(一):初始化和遍历
笔试总是用到,但是用的不熟练,总结一下:介绍:https://www.cnblogs.com/zhonghuasong/p/5975979.htmlvector是表示可变大小数组的序列容器。就像数组一样,vector也采用的连续存储空间来存储元素。也就是意味着可以采用下标对vector的元素进行访问,和数组一样高效。但是又不像数组,它的大小是可以动态改变的,而且它的大小会被容器自动处理。本质讲,...原创 2018-07-09 11:14:14 · 894 阅读 · 0 评论 -
单例模式及C++实现代码
这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。 这种模式涉及到一个单一的类,该类负责创建自己的对象,同时确保只有单个对象被创建。这个类提供了一种访问其唯一的对象的方式,可以直接访问,不需要实例化该类的对象。 注意: 1、单例类只能有一个实例。指向唯一实例的静态指针 2、单例类必须自己创建自己的唯一实例。 3、单例类必须给所有其他对象提供这一实例。 4、唯一一个公有函...原创 2018-09-10 22:09:26 · 1819 阅读 · 0 评论