Re: I am confused with these concepts.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"rockdale" <rockdale.green@xxxxxxxxx> wrote in message news:dd0ac1c1-right?

in this case (returning class), the myClass is automatic variable and
is destroyed when it goes
out of scope this function, right? But because we return myClass, so
the content of myClass is COPIED to the caller?
Still, in this case, I still did not see the necessary to use
pointer.

----------------------------------------

Your concept is correct.

It's up to you to decide whether to use a pointer or not. Obviously, copying a pointer value is very cheap. Depending on the class, copying a class instance might be very expensive.

Brian



.



Relevant Pages

  • Re: why no copy constructor in java?
    ... Here only the pointer value is copied, both pointers will then point to ... MyClass Obj_1 = MyClass; ... default memberwise shallow copy then Obj_1 and Obj_2 will both have ... > behaviour(shallow copying) is usually un-acceptable. ...
    (comp.lang.java.programmer)
  • Re: TRICK: Unique IDing
    ... > pointer to the target instance or a pointer to a copy of the target ... When passing an instance of a class it can be done so the ... > class MyClass ... > you want ) and compare it against the suspect. ...
    (microsoft.public.dotnet.languages.vc)
  • TRICK: Unique IDing
    ... Sometimes it's hard to get straight when passing or storing or returning an ... pointer to a copy of the target instance. ... class MyClass ... ID) and compare it against the suspect. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Conversion from void* to a point of a class
    ... Well, that is true, dynamic_cast does not work for void-pointers - once you have converted your MyClass* pointer to a void* you have voluntarily given up all type information and there is no safe way back. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Pointers in VC.Net
    ... that you may not actually need to create a pointer for your specific needs ... The .Net platform supports passing objects around as references ... MyClass class = new MyClass; ... What language are you using? ...
    (microsoft.public.dotnet.framework.clr)