Thread: Linked list trouble...

  1. #1
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51

    Question Linked list trouble...

    Hi all,

    I'm reading lines of data from a file & storing them into variables (successfully) however when I try to create an object instance with the data & add it to a linked list I get an error.

    Code:
                // Insert a new member to MapClass list
                mapLocationClass* tempLocation = new mapLocationClass( tempLocationID, tempLocationName, tempLocationDescription );
    
                insertAtFront( tempLocation );
    The error is:
    Invalid conversion from 'mapLocationClass*' to 'int'
    initializing argument 1 of 'mapLocationClass::mapLocationClass(int)'

    I'm aware that this seems to be a problem with my mapLocationClass constructor, however I don't have a constructor which sets only the integer locationID. The constructor I have sets the integer & the two strings at the same time. o_O

    Where should I look to find the solution?

  2. #2
    Registered User
    Join Date
    Oct 2010
    Posts
    45
    Your not actually sending a mapLocationClass object, your sending a pointer to it. Maybe try dereferencing the pointer. Unless your error is occuring on construction, then its in your class and you should post it as well.
    Last edited by Incantrix; 11-26-2011 at 03:37 PM. Reason: typo

  3. #3
    Registered User JM1082's Avatar
    Join Date
    Mar 2011
    Posts
    51
    That worked a treat! Thanks so much!!! :^)

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Is there a need for new at all, though?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with linked list
    By mikeman in forum C++ Programming
    Replies: 8
    Last Post: 01-21-2010, 11:10 PM
  2. trouble printing linked list
    By deathrattle in forum C Programming
    Replies: 3
    Last Post: 12-02-2008, 06:29 PM
  3. trouble printing linked list
    By deathrattle in forum C Programming
    Replies: 3
    Last Post: 12-02-2008, 05:33 PM
  4. Linked list trouble
    By sand_man in forum C Programming
    Replies: 2
    Last Post: 02-08-2005, 01:14 PM
  5. Having trouble with Linked List
    By hkmixxa in forum C++ Programming
    Replies: 7
    Last Post: 08-09-2004, 03:25 AM