I'm following a linked list implementation from a textbook and I'm getting the error "call to constructor of 'Node' is ambiguous in this private function within my LinkedList.cpp:
void P1LinkedList::init(){
theSize = 0;
head = new Node; //causes error
tail = new Node; //causes error
head->next = tail;
tail->prev = head;
}
This is my Node.h:
#ifndef Node_h
#define Node_h
struct Node{
int data;
Node* next;
Node* prev;
Node(const int & d = 0, Node *p = nullptr, Node *n = nullptr);
Node(int && d = 0, Node *p = nullptr, Node *n = nullptr);
};
#endif
And my Node.cpp:
#include "Node.h"
#include<iostream>
Node::Node(const int & d, Node *p, Node *n)
:data{d}, prev{p}, next{n}{}
Node::Node(int && d, Node *p, Node *n)
:data{std::move(d)}, prev{p}, next{n}{}
I'm guessing it has to do with how I've written the Node constructors, but I've written it according to my textbook's outline so I'm not sure what I've done wrong.