why and where do we use nameless object?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • murari jangid
    New Member
    • Mar 2013
    • 1

    why and where do we use nameless object?

    tell me past so preparing...why we use this object and what purpose we use it
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Obviously a nameless object can't be referenced by us but it can be referenced by the compiler.

    Suppose you have:

    Code:
    string MyFunction();
    
    string x = MyFunction();
    Here MyFunction returns a string object that you assign to string x. That returned string object is a nameless object. It only exists to get from the called function back to your string x. Then it disappears.

    Comment

    • whodgson
      Contributor
      • Jan 2007
      • 542

      #3
      When you reserve memory using 'new' for say an object,the object is essentially nameless however its address is held by the pointer to which it is assigned...I think.

      Comment

      Working...