Like Tree3Likes

Does the following code show undefined behaviour ?

This is a discussion on Does the following code show undefined behaviour ? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by manasij7479 What I can't understand : how does returning a reference allow such corruption ? Originally Posted ...

  1. #31
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,739
    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
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    .... 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 ...
    laserlight likes this.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #33
    Registered User
    Join Date
    Apr 2006
    Posts
    2,053
    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.

Page 3 of 3 FirstFirst 123
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, 01:11 PM
  4. Is this undefined behaviour?
    By caduardo21 in forum C Programming
    Replies: 4
    Last Post: 01-15-2006, 11:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21