[問題] 請問使用template的error
新手第一次使用function template
程式碼如下
template <class T> T** G(int nRows, int nCols)
{
T **ppi;
T *pool;
T *curPtr;
ppi = new T*[nRows];
pool = new T [nRows * nCols];
curPtr = pool;
for( int i = 0; i < nRows; i++)
{
*(ppi + i) = curPtr;
curPtr += nCols;
}
return ppi;
}
main呼叫時
int main(int argc, char *argv[])
{
double **d = G(5,3);
system("PAUSE");
return EXIT_SUCCESS;
}
即出現錯誤
no matching function for call to `G(int, int)'
第一次使用 function template,請問這該怎麼解決呢
希望大家不吝指導
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.103.207
推
02/11 13:49, , 1F
02/11 13:49, 1F
→
02/11 13:50, , 2F
02/11 13:50, 2F
→
02/11 13:50, , 3F
02/11 13:50, 3F
→
02/11 14:00, , 4F
02/11 14:00, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章