October 28th, 2010, 02:10 AM
#1
help me in this code ..
hi all,
Suppose myList points to a list with the elements 34 65 27 89 12 (in this order). The statement
myList.splitMid(sublist);
splits myList into two sublists: myList points to the list with the elements 34 65 27, and sublist points to the sublist with elements 89 12.
i receive an error in linkedList.h
please help !! the file in attachment
Attached Files
October 28th, 2010, 03:07 AM
#2
Re: help me in this code ..
Hi,
in your attachement there are 2 headers and one source file. Since that is not a compileable project, what do you expect us to do?
Isn't it possible to tell us the error? Post the code (in code tags) and tell us the error you got.
I do not have the time to build a project out of your files...
With regards
Programartist
October 28th, 2010, 08:20 AM
#3
Re: help me in this code ..
sorry for that
the error is her (((((( secondList = first ))))
void linkedListType<Type>::splitAt(linkedListType &secondList,
const Type& item)
{
//void splitAt(List <Type> &seclist, const Type &item){
nodeType<Type> * first;
nodeType<Type> * link;
nodeType<Type> *pNode = first ;
bool found = false;
if (isEmptyList())
cout<< "The List is empty\n";
else
for (pNode = first; pNode != NULL; pNode = pNode->link)
if (item == pNode->info){
first = pNode;
secondList = first;
found = true;
}
if (found = false){cout<<"Item not found";}
}
#endif
October 28th, 2010, 08:23 AM
#4
Re: help me in this code ..
Victor Nijegorodov
October 28th, 2010, 08:26 AM
#5
Re: help me in this code ..
Code:
nodeType<Type> * first;
nodeType<Type> *pNode = first ;
Always initialize your variables.
Code:
nodeType<Type> * first = NULL ;
nodeType<Type> *pNode = first ;
Now you can see, 'first' is nothing, so 'pNode' also is nothing.
Code:
secondList = first;
'secondList' is a refference, not a pointer. Also, it is of a different type.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width