template<typename T>
void testMC(cv::Mat_<T>& One, int sum)
{
int* ptr2 = &One.ptr<int>(0)[0]; //assig the address of the first pixel
// to the U* ptr2
//this function would cause some problem
//if I simply neglect typename U but explicitly state the
//type of One, every thing should be fine
//like void testMC(cv::Mat_<cv::Vec3i>& One, int sum), this one is fine
}
void testMultiChannel_CV()
{
using std::cout;
//Vec3i = Vec(int, 3)
cv::Mat_<cv::Vec3i> One(10, 10); //could treat this as
//type int One[3][10][10] array
testMC(One, sum);
int* ptr2 = &One.ptr<int>(0)[0]; //this is OK
}
the error message is
expected primary-expression before 'int'|
The parser doesn't know that One.ptr is a template function ( since it may depend on what T is )
You need to tell it that the '<' would be the beginning of a template parameter and not the less-than operator.
That is done this way: &One.template ptr<int>(0)[0];