Ich erhalte diese Fehlermeldung:Debugging-Hilfe: C++ Fehler
SortedList.cpp:197: error: expected constructor, destructor, or type conversion before '*' token
Dies ist der Code:
197 Listnode *SortedList::copyList(Listnode *L) {
198 Listnode *current = L;
199
200 Listnode *copy = new Listnode;
201 copy->student = new Student(*current->student);
202 copy->next = NULL;
203
204 Listnode *head = copy;
205
206 current = current->next;
207 while (current != NULL) {
208 copy = copy->next = new Listnode;
209 copy->student = new Student(*current->student);
210 copy->next = NULL;
211 }
212 return head;
213 }
Dies ist die Listnode ist:
struct Listnode {
Student *student;
Listnode *next;
};
Listnode *head;
nicht sicher, was ich bin tun soll. Ich habe bereits einen Konstruktor und einen Destruktor implementiert, um sie anzuzeigen. Jeder Einblick, was das Problem möglicherweise ist, wäre hilfreich.
Wo ist 'Listnode' in' SortedList.cpp' oder seine eigene Header-Datei definiert? – keety
In einer Datei SortedList.h. Es ist ein privates Mitglied einer SortedList-Klasse –
dann müssen Sie darauf als SortedList :: Listnode in der Funktionssignatur – keety