Hi there,

I am trying to provide a global function to be used in quite a few classes but I just keep getting linker errors (this is using gcc).
My header file looks like this:
//A simple streamcasting TEMPLATE function

#ifndef _STREAMCAST_H_
#define _STREAMCAST_H_

#include <strstream>
#include <iostream>


template <class Type>
std::string stream_cast( Type const& );

#endif

and my source file like this:
#include "stream_cast.h"
#include <strstream>
#include <iostream>

using namespace std;

template <class Type>
string stream_cast( Type const& from )
{
strstream stream;
string to;
stream << from;
stream >> to;
return to;
}

I seem to get linker errors if I try to call this function even though I am definitely including the header file. Examples of linker error:
This line (where i is an unsigned int):

plot_command+=", \'\' u 1:"+stream_cast(i+1);

produces this

ld: Undefined symbols:
std::basic_string<char, std::char_traits<char>, std::allocator<char> > stream_cast<unsigned>(unsigned const&)

AND (where example is a double)
string title;
title=title+stream_cast(example);

produces this

ld: Undefined symbols:
stream_cast(double const&)

Its weird because it works fine if you include it in one of the class source files and only call it from that source file.

Thanks