Здравствуйте!
Код:
t.h
#pragma once
template<class T>
void fn(T v)
{
std::cout << "common\n";
}
template<>
void fn<double>(double v)
{
std::cout << "spec\n";
}
main.cpp
#include "stdafx.h"
#include "t.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
b.cpp
#include "stdafx.h"
#include "t.h"
Выдаёт ошибку:
Compiling...
main.cpp
Linking...
b.obj : error LNK2005: "void __cdecl fn<double>(double)" (??$fn@N@@YAXN@Z) already defined in main.obj
Debug/main.exe : fatal error LNK1169: one or more multiply defined symbols found
Не подскажете, где я напортачил?