![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c/c++
文章平均质量分 70
winger2010
这个作者很懒,什么都没留下…
展开
-
c++垃圾自动回收类
Chapter 2 of the art of c++#ifndef GC_H_#define GC_H_#include #include #include #include using namespace std;#define DISPLAYclass OutOfRangeExc{ //Add functionality if needed by your appli原创 2011-05-27 17:12:00 · 1096 阅读 · 1 评论 -
c++模拟foreach关键字
最近研究《the art of c++》一书,其中,第四章扩展了一些C++的关键词,比如foreach,cases,typeof等等。下面是第四章foreach功能的复现。功能:翻译文件中的foreach([type] v in array),为for( [type] v = array[0], _ia = 0; _ia _ia++, v = arra原创 2011-05-27 16:58:00 · 1236 阅读 · 0 评论 -
java string.split()函数的c/c++两种实现——strtok_r及string.find()
目标:写一个类似与java中string.split()的函数,用语c++中字符串的分割。发现c库中有strtok函数有近似的功能,但是不能直接得到所有结果。最终代码:头文件:其中,必须包含iostream,不知道为什么。#ifndef _STRINGSPLITER_H#define _STRINGSPLITER_H#include #include using nam原创 2011-11-15 10:43:32 · 2180 阅读 · 0 评论 -
矩阵行列式求解的递归和非递归算法代码(已通过Matlab验证)
递归算法:double determinant(double **matrix,int dim){ double result = 0; int i,k; double **subMatrix = (double **) new double*[dim]; for(i = 0; i < dim; i++) subMatrix[i] = (double *) new double[原创 2010-11-11 21:13:00 · 2110 阅读 · 0 评论 -
c++ map::operator[]陷阱——无则插入
T& operator[] ( const key_type& x );Access elementIf x matches the key of an element in the container, the function returns a reference to its mapped value.If x does not match the key of原创 2012-02-22 14:38:57 · 1566 阅读 · 0 评论 -
C++ stl编程之Vector删除后iterator可能失效
问题描述: vector > trips存的指针指向vector dstAvOptions中的AvailJaourneyOption。当程序需要增加AvailJaourneyOption到dstAvOptions时,会引起trips中所有指针失效的问题。问题代码://! 生成noTripDate中日期的同天行程组合,并保留tirp和相应Av信息//! @param [in原创 2012-11-08 10:49:12 · 1540 阅读 · 0 评论 -
用berkelyDB持久化memcached时bug解决过程记录——第一次读取报MEMCACHED_UNKOWN_READ_FAILURE错误
【问题背景】 我们的程序是一个基于tuxedo交易中间件发布的服务,以.so方式更新程序,起停serveice。由于memcached在程序重启之后,已有缓存数据会全部失效,在访问量大且数据变化较小的情况下,会造成顺时延时长。所以用嵌入式轻量级数据库berkeleyDB(以下简称bdb)对其进行改造: 1)存memcached同时,存入bdb;原创 2012-11-08 13:50:14 · 2403 阅读 · 0 评论