Linked List using classes

Hello everyone, I'm creating a program that has two classes: one for the Node and another one for the Linked List. Everything so far looks good but I'm getting a compile error. On line 28, I have the print all function, and on line 58 I have an insert new node function. When I compile, I get these messages:

cpp:61: error: new types may not be defined in a return type
cpp:61: error: two or more data types in declaration of `printAll'
cpp:61: error: prototype for `SLL SLL::printAll()' does not match any in class `SLL'
cpp:28: error: candidate is: void SLL::printAll()
cpp:61: error: `SLL SLL::printAll()' and `void SLL::printAll()' cannot be overloaded


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  #include <iostream>
using namespace std;

class Node{
      
      public:
             
      char letter;  /*I looked up ASCII codes, 65 stands for 'A', 
                     *it will help me make my linked list faster*/
      Node *next, *prev;          //Node pointers to next and previous
      
};


class SLL{
      
 private:
         
         Node *head, *tail;       //Node pointers to head and tail
         
         
 public:
        
        SLL(){               //default constructor
        head = NULL;
        tail = NULL;
        }
        void printAll();
        void insertToFront(char item);
        void deleteFront();
        void insertToBack(char item);
        void deleteBack();           //will delete current back Node
        
        void deleteKthNodeFromBack(int k); /*will delete the k-th node counting from the back 
                                             of a SLL. A->B->-C->D->E->F
                                             deleteKthNodeFromBack(3) will delete D. The SLL will become A->B->-C->E->F. 
                                             front points to A, back points to F
                                             If we call it again deleteKthNodeFromBack(5) will delete A.
                                             The SLL will become B->-C->E->F. front points to B, back points to F
                                             If we call it again deleteKthNodeFromBack(5) will delete nothing because there 
                                             is only 4 nodes.*/
                                             
        void reverse(); /*will reverse the contents a SLL. For example:
                               A->B->C->D will become
                               D->C->B->A. front points to D, back points to A*/
                               
        void deleteDuplicate(); /*will delete all duplicate nodes in a SLL. For example:
                                A->A->E->B->B->C->D->D->C->E will become
                                A->E->B->C->D*/
             
        void shiftKNodes(int k); /*The function will shift/rotate k number of nodes. For 
                                 example:
                                         A->B->-C->D->E->F
                                         shiftKNodes(2) will become C->D->E->F->A->B. front points to C. back points 
                                          to B.*/
      
        void insertNewNode(char item);
}


     void SLL::printAll(){
     
     Node *p;
     p = head;
     while(p->next!=NULL){
     
     cout << p << " ";
     p = p->next;
     } 
     
} 

     void SLL::insertNewNode(char item){
          Node* temp;
          
          temp = new Node;
          temp->letter = item;
          temp->next = head;
          head = temp;
          
          
          }

int main(){
    
    SLL list;
    list.insertNewNode('C');
    list.insertNewNode('B');
    list.insertNewNode('A');
    
    
    
    
    system("pause");
    
    return 0;
    
    
}
never mind, I found it. I was missing a semicolon after SLL class
Topic archived. No new replies allowed.