help-octave
[Top][All Lists]
Advanced

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

Re: Did I miss something about structures and function handles


From: James Sherman Jr.
Subject: Re: Did I miss something about structures and function handles
Date: Sat, 18 Aug 2007 16:13:02 -0400

I think he means if the structure has fields, xx, yy, and f, something like
b.xx = 10;
b.yy = 7;
could he write a function f like this:
b.f=@(X)(xx+yy+X)

where xx and yy refer to the other fields in the b structure (something like this->xx if this was in C++), which I don't think is possible in octave.  But I don't have a good grasp of what OOP really and truly means, so the 90% of OOP comment by kensmith confuses me.  I usually think of it in terms of could be done in C (not OOP) vs. C++ (is OOP), but everything kensmith wrote in his email seems to not be OOP to me.  It is just a struct with a field that is a function (or function pointer).  I could be way off base though.

James


On 8/18/07, Matthias Brennwald <address@hidden> wrote:
On 18.08.2007, at 19:04, address@hidden wrote:

> I can say:
>
> b.a=@(X)(disp(X-3))
>
> if I then say
>
> c = b
> c.a(7)
>
> I get 4 as expected.
>
> This looks to me like 90% of object oriented programming is in octave.
> Is there some way that I can get at the other elements of "b" and "c"
> from the member "a".

Which 'other elements' of b and c do you mean? In your example above,
I can see only one element (a) in b and c.

Matthias


-------
Matthias Brennwald
Lägernstrasse 6
CH 8037 Zürich
+41 (0)44 364 17 03
address@hidden



_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

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