读书人

急问! 关于std:list的有关问题 必加分

发布时间: 2012-02-04 15:43:09 作者: rapoo

急问!! 关于std::list的问题 必加分!!!
急问!! 关于std::list的问题 必加分!!!

现在定义了函数指针
void (* printDoc) (std::list <std::string> & oMyPrintList);

怎么使用这个函数指针呢?
初始化了一个指针pPrintInfo

pPrintInfo-> printDoc(std::list <std::string> & oOutPutList);

老是编译有错误:
error C2275: '_STL::list <class _STL::basic_string <char,class _STL::char_traits <char> ,class _STL::allocator <char> > ,class _STL::allocator <class _STL:
:basic_string <char,class _STL::char_traits <char> ,class _STL::allocator <char> > > > ' : illegal use of this type as an expression


pPrintInfo-> printDoc(std::list & oOutPutList);
这样也不行
error C2275: '_STL::list ' : illegal use of this type as an expression

怎么回事? 谢谢!!!!!

[解决办法]
pPrintInfo-> printDoc(oOutPutList);

[解决办法]
呃,楼主啊,你C语言书函数调用章节都没看过吗?
要调一个函数,就要给它参数。通过函数指针来调函数,也是调函数,也要给它参数。
你当然是先要定义一个std::list <std::string> oOutPutList;这样的变量来作参数呀。

读书人网 >C语言

热点推荐