导航

随笔分类 -  C++

摘要:#include#include#include#include#include#include#include#include#include#include#include#include#include /* 创建UDP套接口 */ struct sockaddr_i... 阅读全文

posted @ 2016-01-24 11:56 ggzone 阅读(493) 评论(0) 推荐(0)

摘要:五种迭代器:在STL中,迭代器主要分为5类,分别是:输入迭代器、输出迭代器、前向迭代器、双向迭代器和随机访问迭代器。 输入迭代器 :只读,支持++、==、!=; 输出迭代器 :只写,支持++; 前向迭代器 :读写,支持++、==、!=; ... 阅读全文

posted @ 2016-01-15 11:18 ggzone 阅读(197) 评论(0) 推荐(0)

摘要:下面是一个要用到mysql库的C++程序设置: 添加用户头文件: 双击项目—Build Settings—Search Paths: Library Search Paths: /usr/local/lib User Header Search Paths: /usr/local/i... 阅读全文

posted @ 2016-01-10 12:06 ggzone 阅读(986) 评论(0) 推荐(0)

摘要:判断类中是否有指定名称的函数:#include#define HAS_MEMBER(member)\template\struct has_member_##member\{\private:\ template \ static auto Check(int)->dec... 阅读全文

posted @ 2015-09-13 21:24 ggzone 阅读(328) 评论(0) 推荐(0)

摘要:转自:http://blog.csdn.net/haoel/article/details/1948051测试代码:class Base {public: virtual void f() { cout f(); //Derive::f() b2->f(); //Deri... 阅读全文

posted @ 2015-09-13 19:35 ggzone 阅读(173) 评论(0) 推荐(0)

摘要:1.下面程序在x64下结果struct st{ int a; long long b; double c;};int main() { st s; cout fun(); delete a; system("pause"); retu... 阅读全文

posted @ 2015-09-11 19:45 ggzone 阅读(193) 评论(0) 推荐(0)

摘要:http://zm8.sm-img2.com/?src=http%3A%2F%2Fwww.w2bc.com%2FArticle%2F38320&uid=57422b713ac761e653af7b327bfd9c21&hid=72d420808a7f5a549c1810ca5934... 阅读全文

posted @ 2015-09-05 11:04 ggzone 阅读(285) 评论(0) 推荐(0)

摘要:VS2015下测试: decltype:class Foo {};int &func_int_r(void) { int i = 0; return i; };int &&func_int_rr(void) { return 0; };int func_int(void) { ret... 阅读全文

posted @ 2015-09-05 10:54 ggzone 阅读(324) 评论(0) 推荐(0)

摘要:返回值优化(Return Value Optimization,简称RVO),是这么一种优化机制:当函数需要返回一个对象的时候,如果自己创建一个临时对象用户返回,那么这个临时对象会消耗一个构造函数(Constructor)的调用、一个复制构造函数的调用(Copy Constructo... 阅读全文

posted @ 2015-09-04 15:05 ggzone 阅读(532) 评论(0) 推荐(0)

摘要:在全局变量前添加const或者static,则该变量链接性为内部,即文件内有效。可以使用extern声明为外部。如果要让函数的链接性为内部,则函数声明和定义都应使用static关键字。 例子:test.hextern int index;static void fun();test.... 阅读全文

posted @ 2015-09-04 11:14 ggzone 阅读(229) 评论(0) 推荐(0)

摘要:六个默认函数:构造函数(construct)析构函数(destruct)复制构造函数(copy construct)赋值(assign)移动构造函数(move construct)移动赋值(move)测试代码:#include using namespace std;int g_co... 阅读全文

posted @ 2015-09-04 10:39 ggzone 阅读(508) 评论(0) 推荐(0)

摘要:步骤:下载protobuf-2.6.1.zip和protoc-2.6.1-win32.zip,地址:https://github.com/google/protobuf/tags到目录protobuf-2.6.1\vsprojects下打开protobuf.sln将项目libprot... 阅读全文

posted @ 2015-09-01 18:48 ggzone 阅读(1642) 评论(0) 推荐(0)

摘要:步骤: 1. 安装MySQL数据库 2. 项目属性页->C/C++->常规->附加包含目录:xxx\MySQL Server 5.6\include 3. 项目属性页->链接器->常规->附加库目录:xxx\MySQL Server 5.6\lib 4. 项目属性页->链接器... 阅读全文

posted @ 2015-09-01 14:23 ggzone 阅读(584) 评论(0) 推荐(0)

摘要:指针初始化为NULL,指向NULL指针区(大小64K),如果读取或写入这个地址,会引发内存写保护异常 版权声明:本文为博主原创文章,未经博主允许不得转载。 阅读全文

posted @ 2015-04-28 11:05 ggzone 阅读(222) 评论(0) 推荐(0)

摘要:// convert string to wstringstd::wstring to_wstring(const std::string& str, const std::locale& loc = std::locale()){ std::vector buf(str.size()); std:... 阅读全文

posted @ 2014-11-30 21:25 ggzone 阅读(346) 评论(0) 推荐(0)

摘要:// move example#include // std::cout#include#include#includeusing namespace std;templateostream& operator& t1){ os ::print(os, t1); os struct PRI... 阅读全文

posted @ 2014-11-29 15:29 ggzone 阅读(205) 评论(0) 推荐(0)

摘要:list::iterator pos; //list coll;for(pos=coll.begin();pos!=coll.end();++pos)这里使用“前置式递增”++pos,因为它比“后置式递增”pos++效率高。后者需要一个额外的临时对象,它必须存放迭代器的原本位置并将它返回。所以一般情... 阅读全文

posted @ 2014-07-13 10:11 ggzone 阅读(333) 评论(0) 推荐(0)