المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Templated Constructor



C++ Programming
09-18-2009, 08:30 AM
When I do this in VC++ 2005:


#include

class Test
{
public:
template
Test(T *a, T *b)
{
}
};

int main(void)
{
std::list integerList;
Test t(integerList.begin(), integerList.end());

return 0;
}


I get the following error:

error C2660: 'Test::Test' : function does not take 2 arguments

This is an example to show the problem, but my real goal is to have a templated constructor that takes two iterators and uses them to fill an internal collection. I don't want the constructor to depend on the iterator types, i.e. the constructor shouldn't care if the iterators are from a list, vector, or raw pointers to an array.