template function error..

Posted by sil3nt on Stack Overflow See other posts from Stack Overflow or by sil3nt
Published on 2010-06-08T05:25:37Z Indexed on 2010/06/08 5:32 UTC
Read the original article Hit count: 155

Filed under:
|
|
|

Hi there, I have function which takes in an parameter of a class called "Triple", and am returning the averge of 3 values of type float.

template <typename ElemT>
float average(Triple ElemT<float> &arg){
    float pos1 = arg.getElem(1);
    float pos2 = arg.getElem(2);
    float pos3 = arg.getElem(3);

    return ( (pos1+pos2+po3) /3 );
}

when i try compiling this i get

q2b.cpp:32: error: template declaration of `float average'
q2b.cpp:32: error: missing template arguments before "ElemT"

not quite sure what this means.

© Stack Overflow or respective owner

Related posts about c++

Related posts about templates