CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2010
    Posts
    17

    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 Attached Files

  2. #2
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    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

  3. #3
    Join Date
    Oct 2010
    Posts
    17

    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

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: help me in this code ..

    Victor Nijegorodov

  5. #5
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    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
  •  





Click Here to Expand Forum to Full Width

Featured