首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

函数对象 的有关问题 帮忙看看

2012-02-15 
函数对象 的问题帮忙看看#pragmaonce#include stdafx.h#includefunctional#includealgorithmusing n

函数对象 的问题 帮忙看看
#pragma once
#include "stdafx.h"
#include<functional>
#include<algorithm>

using namespace std;

template<class T>
CString convert_char( const T& value)
{
CString strRet;
strRet.Format(_T("%d"), value);
return strRet;
}

template<class T> struct Convert : public unary_function<T, CString>
{
CString strRet;
public:
CString operator() (const T& value ) 

return strRet += convert_char<T>(value);
}

CString result()

return strRet;
}
};

template<class VL, class T>
void convert_array(VL it_begin, VL it_end, CString& strBuf)
{
Convert<T> Res;
for_each( it_begin, it_end, Res);
strBuf = Res.result();
}

然后测试的时候发现 
CString str;
int a[10] = {0, 1, 2, 3, 4,5,6,7,8,9};
str = convert_array( &a[0], &a[10], str); ///这里str输出还是空的,各位大侠帮忙看看 谢谢

[解决办法]
sorry 忘了说明一下
代码改成下面的.

热点排行
Bad Request.