help-octave
[Top][All Lists]
Advanced

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

Re: function overloading without dispatch of a class defined in C++


From: Alexander Barth
Subject: Re: function overloading without dispatch of a class defined in C++
Date: Fri, 6 Jan 2012 13:26:54 +0100

On Fri, Jan 6, 2012 at 11:45 AM, c. <address@hidden> wrote:
>
> On 6 Jan 2012, at 11:24, Alexander Barth wrote:
>
>> Dear all,
>>
>> I would like to overload a function (e.g. close) for a custom object
>> defined in C++ (e.g. octave_ncfile defined in the package octcdf).
>> Currently I used dispatch to do this. I created a C++ function ncclose
>> and I used "dispatch('close','ncclose','ncfile');". So that
>>
>> close(instance_of_octave_ncfile)
>>
>> would call
>>
>> ncclose(instance_of_octave_ncfile)
>>
>> However dispatch is now obsolete, but I do not know how I can add a
>> method to the C++ definition of octave_ncfile which is visible from a
>> script.
>>
>> Any help would be greatly appreciated.
>>
>> Best regards,
>> Alex
>
> I think this can be done by creating a file named close.m in a directory 
> named @ncflie
> and put the following in @ncfile/close.m:
>
> function close (file)
>  ncclose (file)
> endfunction
>
> but I am not able to check at the moment

Excellent! This works! I didn't know that your can simply mix the
definition of classes defined in C++ with scripts.

Cheers,
Alex

>
> HTH,
> c.
>
>


reply via email to

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