(Mingw g++ MSYS compiler, Win32)
I'm trying to compile a linked list test I made. It serves no real purpose, but its good practice. Anyways, my compiler is giving me error messages that completely confuse me, I dont see why I'm getting theyse. (Picky compiler... >.>)
Error messages:
Code:
$ g++ C:/Test2.cpp
C:/Test2.cpp: In member function `void WhaWrapper::CoutAll(WhaWrapper, Wha*)':
C:/Test2.cpp:122: error: expected `;' before ')' token
C:/Test2.cpp:128: error: expected primary-expression before '}' token
C:/Test2.cpp:128: error: expected `;' before '}' token
C:/Test2.cpp:128: error: expected primary-expression before '}' token
C:/Test2.cpp:128: error: expected `)' before '}' token
C:/Test2.cpp:128: error: expected primary-expression before '}' token
C:/Test2.cpp:128: error: expected `;' before '}' token
Heres my code, CoutAll is highlighted in red. (Feel free to tell me everything I did wrong with the linked list itself :P.)
Code:
#include <iostream>
using namespace std;
#define Next 4
#define Prev 8
#define Previous 8
typedef struct Wha *Whaa;
typedef struct Wha *List;
struct Wha {
Whaa prev;
Whaa next;
int clams;
};
class WhaWrapper {
private:
Wha Confusing;
public:
WhaWrapper();
WhaWrapper(int I) {Confusing.clams = I;}
void AddElement(Whaa Pre, Whaa Post);
void AddBefore(Whaa Pre, Whaa Post);
void CoutAll(WhaWrapper P, List l);
Whaa First(Whaa Pre);
Whaa FirstNext(Whaa Pre);
Whaa Last(Whaa Pre);
List Add(List l, Whaa Pre, Whaa Post, int I);
List Remove(List l, Whaa Pre);
};
void WhaWrapper::AddElement(Whaa Pre, Whaa Post) {
if(Pre != NULL || Post != NULL)
goto end; //Skips to the end.
Post->prev = Pre->prev;
Post->next = Pre;
if(Pre->prev != NULL)
Pre->prev->next = Post;
Pre->prev = Post;
end:
;}
void WhaWrapper::AddBefore(Whaa Pre, Whaa Post) {
if(Pre != NULL || Post != NULL)
goto end; //Skips to the end.
Post->prev = Pre;
Post->next = Pre->next;
if(Pre->next != NULL)
Pre->next->prev = Post;
Pre->next = Post;
end:
;}
Whaa WhaWrapper::First(Whaa Pre) {
while(Pre != NULL && Pre->prev != NULL)
Pre = Pre->prev;
return Pre;
}
Whaa WhaWrapper::FirstNext(Whaa Pre) {
while(Pre != NULL && Pre->prev != NULL)
Pre = Pre->prev;
return Pre->next;
}
Whaa WhaWrapper::Last(Whaa Pre) {
while(Pre != NULL && Pre->next != NULL)
Pre = Pre->next;
return Pre;
}
List WhaWrapper::Add(List l, Whaa Pre, Whaa Post, int dir) {
if(Post == NULL)
goto end; //Skips to the end.
if(l == NULL)
l = Post;
else {
if(Pre == l && dir == Previous) {
AddBefore(l, Post);
l = Post;
} else {
if(dir == Previous)
AddBefore(Pre, Post);
else
AddElement(Pre, Post);
}
}
return l;
end:
;}
List WhaWrapper::Remove(List l, Whaa Pre) {
if(l == NULL || Pre == NULL)
goto end; //Skips to the end.
if(Pre->prev != NULL)
Pre->prev->next = Pre->next;
if(Pre->next != NULL)
Pre->next->prev = Pre->prev;
if(Pre = l)
l = Pre->next;
return l;
end:
;}
void WhaWrapper::CoutAll(WhaWrapper P, List l) {
Whaa start = P.FirstNext(l);
for(start->next != NULL && start != NULL) {
cout << start.clams << endl;
start = start->next;
start->next = start->next;
start->prev = start->prev->prev;
}
}
int main() {
List l;
WhaWrapper Prim(2);
Wha Pox[3];
int I;
for(I = 0; I != 4; I++) {
Pox[I].next = NULL;
Pox[I].prev = NULL;
Pox[I].clams = I;
Prim.Add(l, Pox[I].next, Pox[I].prev, Next);
}
return 0;
}
Thanks ...