Thread: help with using partial_sum method with my own list

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    2

    help with using partial_sum method with my own list

    Hello,
    So for a program im supposed to use the partial_sum method with my own list. But when i try to compile the program i get two errors that say the same thing: lvalue required as left operand of assignment. I dont know what i can change in my list to make it work. Can anybody help?

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    The error points to this in the standard libraries (with GCC)

    Code:
    *__result = __value;
    and it means that the result of dereferencing your iterator (*__result) must be something that can be assigned to (used on the left side of the assignment operator).

    However, your operator * is defined like this:

    Code:
    const T operator *() const { return current->value; }
    It should return a reference (non-const - for completeness you'd need a separate const_iterator class that returns a const reference):

    Code:
    T& operator *() const { return current->value; }
    Last edited by anon; 05-06-2010 at 02:48 PM.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    2
    thank you so much. that fixed everything =)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. circularly linked list
    By BlackOps in forum C Programming
    Replies: 0
    Last Post: 07-18-2009, 08:12 AM
  2. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 10:01 AM
  3. Problem with linked list ADT and incomplete structure
    By prawntoast in forum C Programming
    Replies: 1
    Last Post: 04-30-2005, 01:29 AM
  4. problem with structures and linked list
    By Gkitty in forum C Programming
    Replies: 6
    Last Post: 12-12-2002, 06:40 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

Tags for this Thread