octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to use the OO features of Octave


From: John W. Eaton
Subject: How to use the OO features of Octave
Date: Tue, 23 Sep 2008 09:39:08 -0400

On 23-Sep-2008, David Bateman wrote:

| Trying to use the OO features of 3.1.51, I fail on a very basic issue. I 
| have a class directory "@myclass" with the constructor
| 
| function b = myclass (a)
|   b.a = a;
|   b = class (b, "myclass");
| endfunction
| 
| When called I get error
| 
| error: class: invalid call from outside class constructor
| error: called from:
| error:   /home/adb014/nobackup/perso/octave/@myclass/myclass.m at line 
| 3, column 5
| 
| what is the issue with the above? Basically, I thought I might try and 
| do some documentation for the OO could with examples, but am failing 
| miserably at the moment.

Are you actually using 3.1.51 or a copy of Octave built from hg?

I think this is one of the embarrassing bugs in 3.1.51 that was fixed
shortly after I made the snapshot.  Your code seems to work with a
build from last night:

  $ cat @myclass/myclass.m
  function b = myclass (a)
    b.a = a;
    b = class (b, "myclass");
  endfunction
  $ octave
  [...]
  octave:1> x = myclass (1)
  octave:2> class (x)
  ans = myclass


jwe


reply via email to

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