Line inside main Node<int> *head = takeInput() is giving error no matching function for call to 'takeInput()'. Can you help me and tell me whats the mistake I am doing here so that I wouldn't do it in future. Thanks!
#include<iostream>
using namespace std;
template<class T>
class Node{
public:
T data;
Node *next;
Node(T x){
data = x;
next = NULL;
}
};
template<typename T>
Node<T> * takeInput(){
T data;
cin>>data;
Node<T> *head = NULL;
Node<T> *tail = NULL;
while(data != -1){
Node<T> *newNode = new Node(data);
if(head == NULL){
head = newNode;
tail = newNode;
}else{
tail->next = newNode;
tail = tail->next;
}
cin>>data;
}
return head;
}
int main(){
Node<int> *head = takeInput();
cout<<head->data;
}