Re: a simple reference variable question

From: Bent Stigsen (ngap_at_thevoid.dk)
Date: 10/02/04

  • Next message: john: "Re: a simple reference variable question"
    Date: Sat, 02 Oct 2004 04:31:23 +0200
    
    

    john wrote:
    [snip]
    > // Insert a variable into an array
    > $x = 0;
    > $arr[] = & $x;
    >
    > // Function returns reference to the first element
    > function & getX() { return $arr[0]; }

    Another simplified example slip :) ?
    You probably know that global variables are not accessible unless
    explicitly specified, like:

    function & getX() {
       global $arr;
       return $arr[0];
    }

    [snip]

    > $myObj = & $myCollection->search("foo");
    > $myObj->name = "bar";

    Anyway, probaly not the problem in your real code, since global is not
    used within classes.
    Are you sure the code in your search method doesn't make a copy of the
    object somewhere?

    /Bent


  • Next message: john: "Re: a simple reference variable question"

    Relevant Pages

    • Re: How to eliminate this global variable, silent?
      ... The Standard does NOT say that there are no ... *are* global variables in C, but you seem loathe to provide either the ... What's the big secret ...
      (comp.lang.c)
    • Re: Globals
      ... Both the languages you've mentioned provide for the ... use of global variables, ... so small projects written in scripting languages allow ...
      (comp.lang.cpp)
    • Re: still a newb Tstringlist
      ... I took that approach at first, it is not the best way of tackling ... Browsing the Help files is pretty painful, but, IMO it is essential ... using them in real code. ...
      (alt.comp.lang.borland-delphi)
    • Re: use a hash from a module within a main program without passing by reference or value
      ... In general, I'd avoid making global variables here, too. ... %MYCOOLHASH = changeValues; ... This can't be your real code; this exit here will cause your main ...
      (comp.lang.perl.misc)
    • Re: Calling procedure
      ... simonZ wrote: ... Any ide why? ... Well, without seeing any of the real code, it's impossible to say. ...
      (microsoft.public.dotnet.languages.csharp)