[Top][All Lists]

[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.


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]