Address of temporary objects

From: Ariel (ariele_at_elbit.co.il)
Date: 10/31/04


Date: 31 Oct 2004 02:28:05 -0800

When passing an object by value to some function foo(), the copy
constructor gets called and inside it i see that the address of the
temporary obect is X.
but when entering to foo() i see that the address of the temporary
object is Y.
By looking at the assembly i think that the copiler copies the
temporary object to a different location after calling the copy
constructor.
Is it legal?
thanks ahead,
Ariel Erenberg



Relevant Pages

  • Re: C++ design question
    ... so anyone can instantiate it without ... > default constructor in the class header rather that allowing it to be ... > separately and initialize a pointer to it in Foo: ... fooDeriveN::DoStuffWithBarBase() at all because we have a Bar* in Foo*. ...
    (comp.object)
  • Re: C++ design question
    ... The default constructor is implied in the initialization list. ... One wants to access Bar at the superclass level to avoid static typing ... Usually that would be done by whoever instantiates a Foo subclass ...
    (comp.object)
  • Re: "x.constructor == Foo" vs "x instanceof Foo"
    ... (x instanceof Foo) ... by examining the value of its first argument's the constructor ... as giving the object graph: ...
    (comp.lang.javascript)
  • Re: getting used to Java - question about "style"
    ... > constructor." ... Let's suppose you create a class Foo ... ... They can also override frob(), because we didn't make it private or final. ... When a new object of type Bar is created, ...
    (comp.lang.java.programmer)
  • Re: New (as in days) to Java - question about "super()" method
    ... > it does make good basic sense to get everything, ... If you have a class Foo that extends Bar, ... You need to have the Bar object in place before you can start ... If your constructor uses no arguments, ...
    (comp.lang.java.programmer)