PDA

Tam Sürümünü Görmek İçin : linked listlerde anlamadığım bir hata


ankakusu
24/12/2007, 22:22
Merhaba arkadaşlar şu aşağıdaki hatanın
nedenini aciklayabilir misiniz?

class LinkedList
{
public:
LinkedList();
virtual ~LinkedList();
void insert(int newItem );
void showAll();
struct node
{
int item;
//node *prev;
node *next;
};
int size;
node *dummyHead;
node *head;
bool recursiveSort(node *ref);
};

LinkedList::LinkedList():size(0)
{
dummyHead = new node;
head = dummyHead;
}

LinkedList::~LinkedList()
{

}

void LinkedList::insert(int newItem )
{
node *n= new node;
n->item = newItem;
n->next = dummyHead->next;//->next;
dummyHead->next = n;
size++;
}

void LinkedList::showAll()
{
node *cur = dummyHead;
cur = cur ->next;
for(int i=0;i<size;i++)
{
cout<<"item "<<i+1<<" is "<<cur->item<<endl;
cur = cur->next;
}

}

bool LinkedList::recursiveSort(node *ref)
{
node *head = ref;
head = head->next;
if(head ==NULL || head ->next == NULL )
{
return true;
}
else
{
return recursiveSort( (head->next)) && (head >head->next);
}

}


int main()
{
cout<<"başladım"<<endl;

LinkedList L;

L.insert(7);
L.insert(3);
L.insert(1);
L.insert(4);
L.showAll();
node *n = L.head;
L.recursiveSort(n);
cout<<"bitirdim"<<endl;
return 0;
}

aldığım hata:


../main.cpp: In function 'int main()':
../main.cpp:104: hata: cannot convert 'LinkedList::node*' to 'node*' in initialization
../main.cpp:105: hata: 'LinkedList::recursiveSort(node*&)' çağrısı ile eşleşen işlev yok
../LinkedList.h:35: bilgi: adaylar: bool LinkedList::recursiveSort(LinkedList::node*)

bu ne demek anlamadım...
yardımcı olur musunuz?


golgepapaz
25/12/2007, 00:04
node* n = L.head

LinkedList::node* n=head olacak...

node structu LinkedListin icinde oldugu icin main'e gorunur degil...

illa oyle kullanicam diyorsan
using LinkedList::node dersen gorunur yapabilirsin.