So i have my linked list class, and my node struct. Here is the code:
struct node{
int data;
node *next;
};
class linkedlist{
private:
node *head, *tail;
public:
linkedlist()
{
head=NULL;
tail=NULL;
}
};
When i call a function which uses head and tail to, for example, add a value, the compiler says that node and tail was not declared in this scope.
EDIT: Here is a function in my main file in which head and tail isnt declared
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "func.h"
using namespace std;
int errorCode;
void add(tADT &adt, tValue value, int pos){
node *pre=new node;
node *cur=new node;
node *temp=new node;
cur=head;
for(int i=1;i<pos;i++)
{
pre=cur;
cur=cur->next;
}
temp->data=value;
pre->next=temp;
temp->next=cur;
}
And my function call:
cin >> val >> pos;
add(adt, val, pos);