static template functions in a class

Define the function in the .h file.

Works fine for me

a.h

#include <vector>
#include <iostream>

using namespace std;
class A {
public:
template< typename T>
    static double foo( vector<T> arr );

};

template< typename T>
double A::foo( vector<T> arr ){ cout << arr[0]; }

main.cpp

#include "a.h"
int main(int argc, char *argv[])
{
    A a;
    vector<int> arr;
    arr.push_back(1);
    A::foo<int> ( arr );
}

 

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)