Hi,
I'm trying to construct my first Doubly Linked List, but am having trouble compiling.
This is my program:
main.cpp :
#include <iostream>
#include "node.h"
#include "doublylinkedlist.h"
using namespace std;
int main()
{
system ("PAUSE");
return 0;
}
node.h :
class Node
{
public:
Node *pointertonextnode;//pointer to the next node of type node
Node *pointertopreviousnode;//pointer to the previous node of type node
int nodedatamember;//a node's data memeber
};
doublylinkedlist.h :
class doublylinkedlist
{
public:
Node *pointertofrontoflist;//pointer to front of list
Node *pointertobackoflist;//pointer to back of list
//constructor to contruct a blank doubly linked list:
doublylinkedlist()
{
pointertofrontoflist = NULL;
pointertobackoflist = NULL;
}
void insertBeginningWhenListIsEmpty(doublylinkedlist List, Node newNode);
};
doublylinkedlist.cpp :
#include "doublylinkedlist.h"
void doublylinkedlist::insertBeginningWhenListIsEmpty(doublylinkedlist List, Node newNode)
{
if(List.pointertofrontoflist == NULL)
{
List.pointertofrontoflist = newNode;
List.pointertobackoflist = newNode;
newNode.pointertonextnode = NULL;
newNode.pointertopreviousnode = NULL;
}
else
{
cout << "Create a Insert before function";
//insert before function
}
}
In Visual Studio, the first compile error reports:
error C2143: syntax error : missing ';' before '*'
Which is the line in bold within the doublylinkedlist.h file.
I can't see the error which would cause this, and so am stumped.
Could anyone point my error?
Many thanks for any help with this!
//-------------------------------------------------
(Full error list if that will help):
error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2061: syntax error : identifier 'Node'
error C2065: 'pointertofrontoflist' : undeclared identifier
error C2065: 'NULL' : undeclared identifier
error C2065: 'pointertobackoflist' : undeclared identifier
error C2061: syntax error : identifier 'Node'
error C2039: 'pointertofrontoflist' : is not a member of 'doublylinkedlist'
see declaration of 'doublylinkedlist'
error C2039: 'pointertofrontoflist' : is not a member of 'doublylinkedlist'
see declaration of 'doublylinkedlist'
error C2065: 'newNode' : undeclared identifier
error C2039: 'pointertobackoflist' : is not a member of 'doublylinkedlist'
see declaration of 'doublylinkedlist'
error C2228: left of '.pointertonextnode' must have class/struct/union