[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
modify in place
From: |
John W. Eaton |
Subject: |
modify in place |
Date: |
Mon, 27 Nov 2000 19:18:23 -0600 |
On 27-Nov-2000, Ben Sapp <address@hidden> wrote:
| How can I modify a variable that is a new user defined type? I want to
| modify the actuall variable. I do not want to make another modified
| instance of the variable. I tried the following piece of code and it
| compiled fine but, ended up crashing on the line in
| "non_const_function()" where I modify some internal variables in
| myclass.
|
| ------------------------------------------------------------
| octave_value &rep = const_cast<octave_value&>(args(0).get_rep());
| octave_myclass &myclass = (octave_myclass &)(rep);
| myclass.non_const_function();
| -------------------------------------------------------------
|
| I want it to work like this from the octave command line:
|
| modify_in_place(a);
|
| Now "modify_in_place" does not return any thing it just changes the
| value of "a".
You can't without changing a fundamental feature of Octave, which
enforces pass by value semantics for function arguments.
jwe
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------