C++ learning
步行者之神
这个作者很懒,什么都没留下…
展开
-
malloc/free与new/delete的区别
相同点:都可用于申请动态内存和释放内存不同点:(1)操作对象有所不同。malloc与free是C++/C 语言的标准库函数,new/delete 是C++的运算符。对于非内部数据类的对象而言,光用maloc/free 无法满足动态对象的要求。对象在创建的同时要自动执行构造函数, 对象消亡之前要自动执行析构函数。由于malloc/free 是库函数而不是运算符,不在编译器控制权限之内转载 2016-05-12 16:52:49 · 274 阅读 · 0 评论 -
list 用法
list容器详解 首先说说STL STL就是Standard Template Library,标准模板库。这可能是一个历史上最令人兴奋的工具的最无聊的术语。从根本上说,STL是一些“容器”的集合,这些“容器”有list,vector,set,map等,STL也是算法和其他一些组件的集合。这里的“容器”和算法的集合指的是世界上很多聪明人很多年的杰作。转载 2016-05-27 17:30:30 · 316 阅读 · 0 评论 -
c++ 之replace函数用法
本文主要针对c++中常用replace函数用法给出样例程序/*用法一: *用str替换指定字符串从起始位置pos开始长度为len的字符 *string& replace (size_t pos, size_t len, const string& str); */int main(){ string line = "this@ is@ a test string!"; l转载 2016-05-17 17:26:09 · 718 阅读 · 0 评论 -
lintcode ----数字组合
回溯法void backtracking(vector> &res,vector &tem,vector &cand,int cur,int n,int left) { map,int> m; if(left==0) { if(m.count(tem)==0)原创 2016-07-04 11:56:19 · 353 阅读 · 0 评论 -
leetcode ----Intersection of Two Arrays
思路:因为set容器不会有重复元素,找到后放到set中,然后再拷贝到vector中(注意copy 函数 比for在复制值的时候效率高!!)vector intersection(vector& nums1, vector& nums2) { vector res; set tem; unordered_map m;原创 2016-07-27 11:04:57 · 319 阅读 · 0 评论 -
Windows socket 通信
#include#include#pragma comment(lib,"ws2_32")//#pragma comment( comment-type ,["commentstring"] ) , comment-type是一个预定义的标识符,指定注释的类型,应该是compiler,exestr,lib,linker之一。 , commentstring是一个提供为comment-typ原创 2016-09-12 11:06:12 · 280 阅读 · 0 评论