I am starting with linked lists. I get these errors when compiling this program:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\buildListForward.cpp" -o "C:\Dev-Cpp\buildListForward.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Dev-Cpp\buildListForward.cpp:4: error: expected constructor, destructor, or type conversion before '*' token
C:\Dev-Cpp\buildListForward.cpp:4: error: expected `,' or `;' before '*' token
C:\Dev-Cpp\buildListForward.cpp:5: error: expected constructor, destructor, or type conversion before '*' token
C:\Dev-Cpp\buildListForward.cpp:5: error: expected `,' or `;' before '*' token
C:\Dev-Cpp\buildListForward.cpp: In function `int main()':
C:\Dev-Cpp\buildListForward.cpp:35: error: `buildListForward' undeclared (first use this function)
C:\Dev-Cpp\buildListForward.cpp:35: error: (Each undeclared identifier is reported only once for each function it appears in.)
Execution terminated
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
|
nodeType *buildListForward();
nodeType *buildListForward()
{
nodeType *first, *last, *newNode;
int num;
cout<<"Enter a list of integers ending with -999.\n";
cin >> num;
first = NULL;
while(num != -999)
{
new = new nodeType;
assert(newNode != NULL);
newNode->info = num;
newNode->link = NULL;
if(first == NULL)
{
first = NULL;
last = NULL;
}
else
{
last->link = newNode;
last = newNode;
}
cin >> num;
} //end while
return first;
} // end buildListForward
int main()
{
buildListForward();
}
|