小女子编写C++程序时遇到一个关于Format函数的错误,不知道该怎么修改,希望各位高手帮忙指教!
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小女子编写C++程序时遇到一个关于Format函数的错误,不知道该怎么修改,希望各位高手帮忙指教!相关的知识,希望对你有一定的参考价值。
这段程序的代码是这样的:
LONG CPortDlg::OnRecvSerialData(WPARAM wParam,LPARAM lParam)
CString strRecv ;
strRecv.Format("%x", wParam);//接收十六进制数
m_strEditReceiveMsg += strRecv;
UpdateData(FALSE); //将接收到的字符显示在接收编辑框中
return 0;
m_strEditReceiveMsg 是在之前定义过的
build时有一个错误:
error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *'
Format这个函数用错了么?里面的参数应该写什么呢?
希望高手帮我看一下,不胜感激!
在使用%x或者%X时,后面的wParam需要确保是一个整型值,而不是一个字符串.
另外,如果你已经确定了的话.把你的代码改成
strRecv.Format(L"%x", wParam);
就好使了. 参考技术A CString::Format的定义是:
void Format( LPCTSTR lpszFormat, ... );
再看LPCTSTR定义是“An LPCWSTR if UNICODE is defined, an LPCSTR otherwise.”
再从你的错误信息中有'const wchar_t *',所以估计你在编译时定义了UNICODE,(每个字符占两字节)
首先查下你的代码里有没有#define _UNICODE,如果有,删了,或改为_MBCS
然后看一下你的集成开发环境里(比如VC6)有没有定义_UNICODE
对于VC,是在project settings对话框里的c/c++下,看看有没有,(你应该能看到WIN32,_WINDOWS等等)有就改为_MBCS
如果你必须要用UNICODE。。。 你就把Format的参数"%x"改为Unicode的吧。 参考技术B 喂~ “小女子”,你就不想知道为什么加个L就能编译过了?!枉费了给你分析了半天错误信息。
谈一下关于C++函数包装问题
在C++中,我们经常遇到在某个特定的时刻,需要将函数进行包装调用,尤其是当我们需要将不同签名的函数放到同一个集合时,由于函数签名不一致导致我们不能直接将各式各样的函数指针放到诸如list这样的集合中,因此对函数进行包装就显得格外重要.现在来介绍一下我写的一个函数包装器.
还是需要用到模板技巧,写这种类库没有模板将是不可能实现的任务,大家顺便学习一下模板编写也挺好的.
还是不废话,先上实例,后贴完整类库,这个类库需要用到前面写的萃取和序列化库,当然了,序列化库是可以被替换的,只要满足接口一致.
这里多废话一句:本人致力于写跨平台的C++开源代码,我之前以及现在以及将来上传的所有代码均以hpp文件发布,这种文件的好处就是可以直接包含到源码里使用,而不需要产生各种烦人的dll或者lib.这个库附带了一个scope_guard文件,也是一个很好的安全调用设计,有兴趣的看看
用例代码(看注释基本就可以了):
#include<iostream> #include "../../traits/traits.hpp" #include "../../serialization/archive.hpp" #include "../../call_helper/call.hpp" using namespace std; int show(char i, int j) { return 1; } struct Stu { int show(char i, int j) { return 1; } }; int main() { // C函数包装 callhelper::call_helper<int(char, int)> helper1(show); helper1.call(‘a‘, 6); // 类成员函数包装 Stu stu; callhelper::call_helper<int(Stu::*)(char, int), Stu> helper2(&stu,&Stu::show); helper2.call(‘a‘, 6); // 另一种形式的C函数包装 callhelper::icall* helper3 = new callhelper::ccall<int(char, int)>(show); //helper3->call(serialization::default_string_iarchive(str)); // 另一种形式的类成员函数包装 callhelper::icall* helper4 = new callhelper::ccall<int(Stu::*)(char, int), Stu>(&stu, &Stu::show); //helper4->call(serialization::default_string_iarchive(str)); // 放到同一集合中 std::list<callhelper::icall*> _list; _list.push_back(helper3); _list.push_back(helper4); std::string str; serialization::default_string_oarchive oarc(str); oarc & ‘a‘ & 6; // 调用 for (std::list<callhelper::icall*>::iterator iter = _list.begin(); iter != _list.end(); ++iter) { (*iter)->call(serialization::default_string_iarchive(str)); } delete helper3; delete helper4; return 0; }
完整的类库截图
// call.hpp #ifndef CALL_INCLUDE #define CALL_INCLUDE #include "call_helper.hpp" #include "param_get_set.hpp" #include "marshal.hpp" #include "scope_guard.hpp" #include "call_wrapper.hpp" #include "call_container.hpp" #endif
// call_container.hpp #ifndef CALL_CONTAINER_INCLUDE #define CALL_CONTAINER_INCLUDE #include "call_helper_config.hpp" #include "call_helper.hpp" #include <list> #include <vector> #include <set> NAMESPACE_CALL_HELPER_BEGIN struct basic_call_container { virtual void call(IArchive& iarc)=0; virtual ~basic_call_container(){} }; //////////////////////////////////////////////////////////// template<typename containertype,typename classtype,typename funtype,int paramc> struct _call_container : public basic_call_container{}; /////////////////////////////////////////////////////////// template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,0> : public basic_call_container { virtual void call(IArchive& iarc) { for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,1> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,2> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,3> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,4> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,5> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,6> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,7> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,8> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,9> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,10> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get10,get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,11> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg11 arg11; typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg11> get11(iarc); param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get11,get10,get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,12> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg12 arg12; typedef typename traits::mfunction_traits<funtype>::arg11 arg11; typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg12> get12(iarc); param_get<arg11> get11(iarc); param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get12,get11,get10,get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,13> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg13 arg13; typedef typename traits::mfunction_traits<funtype>::arg12 arg12; typedef typename traits::mfunction_traits<funtype>::arg11 arg11; typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg13> get13(iarc); param_get<arg12> get12(iarc); param_get<arg11> get11(iarc); param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get13,get12,get11,get10,get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,14> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg14 arg14; typedef typename traits::mfunction_traits<funtype>::arg13 arg13; typedef typename traits::mfunction_traits<funtype>::arg12 arg12; typedef typename traits::mfunction_traits<funtype>::arg11 arg11; typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg14> get14(iarc); param_get<arg13> get13(iarc); param_get<arg12> get12(iarc); param_get<arg11> get11(iarc); param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get14,get13,get12,get11,get10,get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,15> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg15 arg15; typedef typename traits::mfunction_traits<funtype>::arg14 arg14; typedef typename traits::mfunction_traits<funtype>::arg13 arg13; typedef typename traits::mfunction_traits<funtype>::arg12 arg12; typedef typename traits::mfunction_traits<funtype>::arg11 arg11; typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg15> get15(iarc); param_get<arg14> get14(iarc); param_get<arg13> get13(iarc); param_get<arg12> get12(iarc); param_get<arg11> get11(iarc); param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get15,get14,get13,get12,get11,get10,get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,16> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg16 arg16; typedef typename traits::mfunction_traits<funtype>::arg15 arg15; typedef typename traits::mfunction_traits<funtype>::arg14 arg14; typedef typename traits::mfunction_traits<funtype>::arg13 arg13; typedef typename traits::mfunction_traits<funtype>::arg12 arg12; typedef typename traits::mfunction_traits<funtype>::arg11 arg11; typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg16> get16(iarc); param_get<arg15> get15(iarc); param_get<arg14> get14(iarc); param_get<arg13> get13(iarc); param_get<arg12> get12(iarc); param_get<arg11> get11(iarc); param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get16,get15,get14,get13,get12,get11,get10,get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,17> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg17 arg17; typedef typename traits::mfunction_traits<funtype>::arg16 arg16; typedef typename traits::mfunction_traits<funtype>::arg15 arg15; typedef typename traits::mfunction_traits<funtype>::arg14 arg14; typedef typename traits::mfunction_traits<funtype>::arg13 arg13; typedef typename traits::mfunction_traits<funtype>::arg12 arg12; typedef typename traits::mfunction_traits<funtype>::arg11 arg11; typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg17> get17(iarc); param_get<arg16> get16(iarc); param_get<arg15> get15(iarc); param_get<arg14> get14(iarc); param_get<arg13> get13(iarc); param_get<arg12> get12(iarc); param_get<arg11> get11(iarc); param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get17,get16,get15,get14,get13,get12,get11,get10,get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,18> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg18 arg18; typedef typename traits::mfunction_traits<funtype>::arg17 arg17; typedef typename traits::mfunction_traits<funtype>::arg16 arg16; typedef typename traits::mfunction_traits<funtype>::arg15 arg15; typedef typename traits::mfunction_traits<funtype>::arg14 arg14; typedef typename traits::mfunction_traits<funtype>::arg13 arg13; typedef typename traits::mfunction_traits<funtype>::arg12 arg12; typedef typename traits::mfunction_traits<funtype>::arg11 arg11; typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg18> get18(iarc); param_get<arg17> get17(iarc); param_get<arg16> get16(iarc); param_get<arg15> get15(iarc); param_get<arg14> get14(iarc); param_get<arg13> get13(iarc); param_get<arg12> get12(iarc); param_get<arg11> get11(iarc); param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get6(iarc); param_get<arg5> get5(iarc); param_get<arg4> get4(iarc); param_get<arg3> get3(iarc); param_get<arg2> get2(iarc); param_get<arg1> get1(iarc); for (typename containertype::iterator iter=_container.begin(); iter!=_container.end(); ++iter) { call_helper<funtype,classtype>& c_helper = (call_helper<funtype,classtype>&)(*iter); c_helper.call(get18,get17,get16,get15,get14,get13,get12,get11,get10,get9,get8,get7,get6,get5,get4,get3,get2,get1); } } containertype _container; }; template<typename containertype,typename classtype,typename funtype> struct _call_container<containertype,classtype,funtype,19> : public basic_call_container { virtual void call(IArchive& iarc) { typedef typename traits::mfunction_traits<funtype>::arg19 arg19; typedef typename traits::mfunction_traits<funtype>::arg18 arg18; typedef typename traits::mfunction_traits<funtype>::arg17 arg17; typedef typename traits::mfunction_traits<funtype>::arg16 arg16; typedef typename traits::mfunction_traits<funtype>::arg15 arg15; typedef typename traits::mfunction_traits<funtype>::arg14 arg14; typedef typename traits::mfunction_traits<funtype>::arg13 arg13; typedef typename traits::mfunction_traits<funtype>::arg12 arg12; typedef typename traits::mfunction_traits<funtype>::arg11 arg11; typedef typename traits::mfunction_traits<funtype>::arg10 arg10; typedef typename traits::mfunction_traits<funtype>::arg9 arg9; typedef typename traits::mfunction_traits<funtype>::arg8 arg8; typedef typename traits::mfunction_traits<funtype>::arg7 arg7; typedef typename traits::mfunction_traits<funtype>::arg6 arg6; typedef typename traits::mfunction_traits<funtype>::arg5 arg5; typedef typename traits::mfunction_traits<funtype>::arg4 arg4; typedef typename traits::mfunction_traits<funtype>::arg3 arg3; typedef typename traits::mfunction_traits<funtype>::arg2 arg2; typedef typename traits::mfunction_traits<funtype>::arg1 arg1; param_get<arg19> get19(iarc); param_get<arg18> get18(iarc); param_get<arg17> get17(iarc); param_get<arg16> get16(iarc); param_get<arg15> get15(iarc); param_get<arg14> get14(iarc); param_get<arg13> get13(iarc); param_get<arg12> get12(iarc); param_get<arg11> get11(iarc); param_get<arg10> get10(iarc); param_get<arg9> get9(iarc); param_get<arg8> get8(iarc); param_get<arg7> get7(iarc); param_get<arg6> get
以上是关于小女子编写C++程序时遇到一个关于Format函数的错误,不知道该怎么修改,希望各位高手帮忙指教!的主要内容,如果未能解决你的问题,请参考以下文章
利用Python编写程序,输入一个三位数,分离出各位数上的数字并输出