
C++
seamanj
这个作者很懒,什么都没留下…
展开
-
C++中用TinyXML对XML文件进行解析
最近老师要求的一个项目中需要在C++对XML文件进行解析,原来只在JAVA中做过类似的解析,然后上了某度了一下,最后搜了一篇关于TinyXML的博客,地址如下:http://blog.youkuaiyun.com/mhapdream/article/details/9088363感觉TinyXML比较好用,准备用它来解析.TinyXML下载地址:http://sourceforge.n原创 2015-04-03 12:22:02 · 3835 阅读 · 0 评论 -
关于标准库中的ptr_fun/binary_function/bind1st/bind2nd
转自:http://www.cnblogs.com/shootingstars/archive/2008/11/14/860042.html以前使用bind1st以及bind2nd很少,后来发现这两个函数还挺好玩的,于是关心上了。在C++ Primer对于bind函数的描述如下:“绑定器binder通过把二元函数对象的一个实参绑定到一个特殊的值上将其转换成一元函数对象转载 2015-04-10 21:59:07 · 887 阅读 · 0 评论 -
va_start, va_list, va_end
/*-----------------------------------------------------SCRNSIZE.C -- Displays screen size in a message box(c) Charles Petzold, 1998-----------------------------------------------------*/#include原创 2015-12-05 02:13:22 · 390 阅读 · 0 评论 -
普通指针到智能指针的转换
普通指针到智能指针的转换int* iPtr = new int(42);shared_ptrint> p(iPtr);智能指针到普通指针的转换int* pI = p.get();注意的地方:那就是不要将智能指针与普通指针混用。如果项目允许,坚持使用智能指针,避免原生指针。智能指针与普通指针需要特别特别特别的小心翼翼,比如以下的情况。转载 2016-01-12 23:19:24 · 26929 阅读 · 0 评论 -
How to define a template class in a .h file and implement it in a .cpp file
To compile this class without any errors, you need to put the template specific declaration in a .cpp file, as shown below:Template Class Header FileHide Copy Code// TestTemp.h#ifndef _TE转载 2016-02-16 00:55:03 · 465 阅读 · 0 评论 -
use count of shared_ptr
#include #include class A{};class B{public: void setA(std::shared_ptr spa) { std::cout << spa.use_count() << std::endl; spA = spa; std::cout << spa.use_count原创 2016-02-17 05:02:09 · 740 阅读 · 0 评论 -
GCC Command Options
https://gcc.gnu.org/onlinedocs/gcc-2.95.2/gcc_2.html原创 2017-10-11 22:33:42 · 358 阅读 · 0 评论 -
new函数的底层实现
举个栗子:Complex* pc = new Complex(1, 2); 此处new称为表达式或运算符new,编译器将其转化为一下代码:Complex* pc; try { void* mem = operator new(sizeof(Complex)); // 底层调用malloc函数分配内存 pc = static_cast...转载 2018-07-12 17:48:33 · 6059 阅读 · 1 评论