[R] Operator overloading for custom classes

Sharpie chuck at sharpsteen.net
Tue Mar 23 20:31:00 CET 2010



Chidambaram Annamalai wrote:
> 
> Hi,
> 
> I need some help to get some of the object orientation, specifically the
> methods that overload the basic arithmetic operations, from sample C++
> code to R. I don't have experience with such advanced language features
> inside of R. So I was wondering if some of you could help me out in this
> regard.
> 
> {snip}
> 
> 

For S3 objects:

  ?base::Ops

  http://n4.nabble.com/Operator-overloading-td854452.html#a854452
  http://n4.nabble.com/Overloading-td850827.html#a850828

For S4 objects:

  ?methods::Ops

  http://n4.nabble.com/How-to-define-new-operators-td974842.html#a974842


A good resource for reading material on S4 classes, which are more formally
defined than S3 classes, can be found in the R wiki:

  http://rwiki.sciviews.org/doku.php?id=tips:classes-s4


Hope this can get you started!

-Charlie

-----
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: http://n4.nabble.com/Operator-overloading-for-custom-classes-tp1679467p1679573.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list