I am in my way of studying the linked list chapter of C++..
So i go through this code below intended of understand it.
#include <iostream>
using namespace std;
struct nodeType
{
int info;
nodeType *link;
};
void printList (nodeType *first)
{
nodeType *current;
current=first;
while (current != NULL)
{
cout<<current->info<<" ";
current=current->link;
}
cout<<"\n";
}
nodeType* buildBackward ()
{ nodeType *first, *newNode, *last;
int num;
cout<<"Enter a list of intergers ending with -999."<<endl;
cin>>num;
first=NULL;
while (num!=-999)
{ newNode=new nodeType;
newNode->info=num;
newNode->link=NULL;
if(first==NULL)
{
first=newNode;
last=newNode;
}
else
{
last->link=newNode;
last=newNode;
}
cin>>num;
}
return first;
}
int main()
{
nodeType *first=buildBackward();
printList(first);
system("pause");
return 0;
}
But i do not understand the uses of pointer in this fraction of code(i mean the one on the right,nodeType*) :
nodeType* buildBackward ()
{
............................
}
As far as i know the pointer on the right indicates that the value is fetched from the location.But what it really does on the funtion above?
I just hope that somebody could explain it to me.
Thank You :)