Mam problem. Potrzebuję skorzystać z szablonów w mojej klasie, jednak nie do końca wiem jak. Stworzyłem w konstruktorze tablicę dynamiczną, niestety przy kompilacji wyskakuje mi "error C2533: 'Elementy<typ>::Elementy' : constructors not allowed a return type ". Próbowałem już różnych konfiguracji i nic nie pomaga, a męczę się z tym już bardzo długo. Proszę o pomoc.
.h
#pragma once
#include <iostream>
using namespace std;
template<class typ>class Elementy
{
protected:
typ *tab;
public:
Elementy(int=1);
~Elementy();
};
.Cpp
#include "stdafx.h"
#include "Elementy.h"
using namespace std;
template<class typ>typ Elementy<typ>::Elementy(int i)
{
tab = new typ[i];
}
template<class typ> Elementy<typ>::~Elementy()
{
delete[] tab;
}