Witam, chcę zaimplementować własną listę, gdzie ja tutaj mam błąd, że podany niżej kod nie działa. Chodzi głównie o to, że np. jak mam w konstruktorze "first->..." to IDE nie wykrywa składników first, czyli "next" i "value". Gdy zamieniam klasę z szablonu na normalną, jest ok, ale gdy jest szablonem, to jest powyższy problem.
#include <iostream>
using namespace std;
template <typename value_type>
class List
{
private:
// typy
struct Node {int value; struct Node * next;};
public:
// konstruktory, destruktor
List(int n=0);
// metody publiczne
void print();
private:
// atrybuty
int size;
Node * first;
struct Node * last;
};
template <typename value_type>
List<value_type>::List(int n=0)
{
first=NULL;
last=NULL;
if (n>0)
{
first=new Node;
**first->next=NULL;**
last=first;
for (int i=0;i<n;++i)
{
last->next=new Node;
last=last->next;
}
}
}
template <typename value_type>
void List<value_type>::print()
{
Node * temp=first;
while (temp!=NULL)
{
cout<<temp->value<<" ";
temp=temp->next;
}
}
Z góry wielkie dzięki za pomoc! :)