In the function "Iteratoring List::begin()" { It has a problem " no matching constructor for initialization" for this Iteratoring(head). head is a node pointer and I built a constructor for it. I do not know what the problem is.
List.h
#include "Iteratoring.h"
struct Node {
int data; // value in the node
Node *next; // the address of the next node
/**************************************
** CONSTRUCTOR **
***************************************/
Node(int data) : data(data), next(0) {}
};
class List {
private:
Node *head= nullptr; // head node
Node *tail; // tail node
Iteratoring begin();
public:
};
List.cpp
#include "List.h"
Iteratoring List::begin() {
return Iteratoring(head); //The error is here. no matching constructor for initialization
}
Iteratoring.h
#include "List.h"
class Iteratoring {
private:
Node *current;
public:
Iteratoring(){
current= nullptr;
};
Iteratoring(Node *ptr){
current=ptr;
};
};