Раздельная компиляция c шаблоном функции

Всем привет. Есть 3 файла:

//header.h
#ifndef _HEADER_H_
#define _HEADER_H_

template <typename T> 
void Convertation(T*, const short size);

const short SIZE = 9;

#endif
//help.cpp
#include "header.h"

template <typename T> 
void Convertation(T* array, const short size)
{
    for (short counter = 0; counter != size / 2; ++counter)
    {
        *(array + counter) ^= *(array + (size - 1) - counter);
        *(array + (size - 1) - counter) ^= *(array + counter);
        *(array + counter) ^= *(array + (size - 1) - counter);
    }
}
//code.cpp
#include <iostream>
#include "header.h"

int main(void)
{
    short array[SIZE] {5, 4, 3, 2, 1};

    std::cout << "There are source array:\n";

    for (short counter = 0; counter < SIZE; ++counter)
        std::cout << "array[" << counter << "] = " << array[counter] << std::endl;

    Convertation(array, SIZE);
    std::cout << "There are modificated array:\n";

    for (short counter = 0; counter < SIZE; ++counter)
                std::cout << "array[" << counter << "] = " << array[counter] << std::endl;

    return 0;
}

При компиляции: g++ code.cpp help.cpp

Ошибка:

/usr/bin/ld: /tmp/cckx4G1e.o: in function `main':
code.cpp:(.text+0xea): undefined reference to `void Convertation<short>(short*, short)'
collect2: error: ld returned 1 exit status

Ubuntu OS.


Ответы (0 шт):