[cpp] 函数的默认参数
marryme
beyond0924 at gmail.com
Wed Feb 20 20:54:25 CST 2008
最近开始学习泛型编程,遇到了一个函数的默认参数的问题,具体如下:
template<class T, class ForwardIterator=T::iterator>
class print
{
operator()(T& coll, ForwrdItrator it=coll.begin())
{
copy(it,coll.end(),ostream_iterator<T::value_type>(std::cout," "));
}
}
//现在我已经有了一个list<int> a;
print(a);//编译不能通过,提示begin()找不道所属的class sturct
print(a,a.begin());//编译通过
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codingnow.com/pipermail/cpp/attachments/20080220/d715d71a/attachment.html
More information about the Cpp
mailing list