Doubley Linked List

Elimde bir header dosyası var ve her şey orda tanımlı benim yapmam gereken tek şey bir implementation dosyası oluşturup orada belirli fonksiyonları tanımlamak fakat undefined reference to `DoublyLinkedList::DoublyLinkedList()’ diye bir hata alıyorum. Nasıl düzeltebilirim?

DoublyList.h

#ifndef __DLIST__
#define __DLIST__

class DoublyNode {
public:
	int data;
	DoublyNode* next;
	DoublyNode* prev;

	DoublyNode(int value);
};

class DoublyLinkedList {
private:
	DoublyNode* head;
	DoublyNode* tail;

	int count;

public:
	DoublyLinkedList();

	void push_head(int value);
	void push_tail(int value);
	void insert_pos(int value, int pos);
	void remove_pos(int pos);
	void remove(int value);
	int size();

	/* These are added for evaluation purposes.*/
	DoublyNode* get_head() const {
		return head;
	}

	DoublyNode* get_tail() const {
		return tail;
	}

};


#endif

implementation.cpp

#include "DoublyList.h"
#include <iostream>
using namespace std;

void DoublyLinkedList::push_head(int value){
    DoublyNode* newNode = new DoublyNode(value);
      newNode->data = value;
      newNode->next = NULL;
      newNode->prev = NULL; 
      if(head == NULL) {
        head = newNode;
      } else {
        head->prev = newNode;
        newNode->next = head;
        head = newNode;
      }    
}

void DoublyLinkedList::PrintList() {
      DoublyNode* temp = head;
      if(temp != NULL) {
        cout<<"The list contains: ";
        while(temp != NULL) {
          cout<<temp->data<<" ";
          temp = temp->next;
        }
        cout<<endl;
      } else {
        cout<<"The list is empty.\n";
      }
    }    

buda test etmek için kullandığım kod

#include <iostream>
#include "DoublyList.h"

using namespace std;

int main()
{
    DoublyLinkedList MyList;

  
  MyList.push_head(10);
  MyList.push_head(20);
  MyList.push_head(30);
  MyList.PrintList();
  
  return 0; 
}

Nereden?

Build komutu yanlis, implementation.cpp compile/link edilmiyor muhtemelen.

hata implementation.cpp de var diyor. Peki build komutunu nasıl düzeltebilirim?

Hmm?

Neye benzedigi hakkinda bir fikrim olmadigi icin bir sey soyleyemiyorum.

Headerda prototipi verilen DoublyLinkedList() kurucu fonksiyonunu, implementationda bulamıyor. İmplementationda
DoublyLinkedList::DoublyLinkedList()
{
}

Fonksiyonu yazmayı denediniz mi…