|
-
October 20th, 2010, 12:23 PM
#1
Function Template
I am new to function template. I found that the following code gives an error. The error returned is:
error LNK2019: unresolved external symbol "void __cdecl linspace<double>(double *,double,double,int)" (??$linspace@N@@YAXPANNNH@Z) referenced in function _wmain
The following are my codes:
In main.cpp:
#include "stdafx.h"
#include "helper.h"
int _tmain(int argc, _TCHAR* argv[])
{
int m=91,n=61;
int i,j;
double* x,y;
double X[]={0.0,1.5},Y[]={0.0,1.0};
double*psi;
x=new double[n];
linspace<double>(x,X[0],X[1],n);
....
In helper.h
template <typename T>
void linspace(T*x,T start,T end,int length);
In helper.cpp
template <typename T>
void linspace(T* x,T start,T end,int length)
{
T h;
h=(end-start)/(length-1);
for(int i=0;i<length;i++)
{
x[i]=start+i*h;
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|