Thread: Does the following code show undefined behaviour ?

  1. #31
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by manasij7479 View Post
    What I can't understand : how does returning a reference allow such corruption ?
    Quote Originally Posted by manasij7479 View Post
    The next, prev pointers are private.
    The data stored by them are public.
    Quote Originally Posted by manasij7479 View Post
    They are private.
    Returning a reference would only allow the modification of the 'value' of a node... or accessing the next node's reference.
    You're starting to make contradictory statements about your design. I either can get at the links because they're exposed or I can't.

  2. #32
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    .... That is because we are debating without the code ....
    Some of the facts did not translate accurately to my words !
    ... I'd (tomorrow) post the code in another thread ...

  3. #33
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Quote Originally Posted by manasij7479 View Post
    ... I plan to have both ! ..
    Stick with iterators. No need to expose implementation details.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Behaviour (Palindromic Number Finder)
    By pobri19 in forum C++ Programming
    Replies: 12
    Last Post: 09-28-2008, 04:54 AM
  2. Undefined behaviour telnet
    By stevesmithx in forum Tech Board
    Replies: 0
    Last Post: 04-22-2008, 01:41 AM
  3. bit shifting...undefined behaviour?
    By Sebastiani in forum C++ Programming
    Replies: 15
    Last Post: 11-07-2007, 02:11 PM
  4. Is this undefined behaviour?
    By caduardo21 in forum C Programming
    Replies: 4
    Last Post: 01-15-2006, 12:55 PM