Witam!
Mam problem. Otóż mam szablon klasy:
template <class typ>
class FIFO
{
struct element
{
typ* wsk;
time_t czas;
struct element* next;
};
struct element* lista;
public:
FIFO();
FIFO(FIFO<typ> & a);
~FIFO();
void wypisz();
FIFO<typ>& operator=(FIFO<typ> k2);
FIFO<typ> operator+(FIFO<typ> &k2);
};
z przeładowanymi operatorami poza ciałem klasy.
Gdy teraz w funkcji main wywołam:
FIFO<int> k1,k2,k3;
//......wypelnienie kolejek
k1=k2;
k3=k2;
//.... wypelnienie kolejek
(k1+k2).wypisz();
Program się kompiluje i działa tak jak powinien.
Jednak gdy wpiszę:
k3=k1+k2;
to kompilator (wbudowany w DevCpp oraz g++) wyrzuca takie komunikaty:
In function `int main(int, char**)':
no matching function for call to `FIFO<int>::FIFO(FIFO<int>)'
candidates are: FIFO<typ>::FIFO(FIFO<typ>&) [with typ = int]
initializing argument 1 of `FIFO<typ>& FIFO<typ>::operator=(FIFO<typ>) [with typ = int]'
[Build Error] [main.o] Error 1
Co robię źle?</cpp>