xpp {
/* Define the XFarm class with the Add
method */
class XFarm {
construct {
public:
<MyCow
breed="Friesian">Bessie</MyCow>
}
public:
int Add(int a, int b) {
return a + b;
};
};
/* Instantiate MyFarm */
node(XFarm) MyFarm;
/* Define some variables and an array */
int iAleph
= 5;
int iBeth
= 7;
int iVal[2]
= {10, 20};
/* Display the values of the array
elements */
xout("\r\niVal[0] = " +
iVal[0]);
xout("\r\niVal[1] = " +
iVal[1]);
/* Invoke the Add method and write its
output 3 different ways */
xout("\r\nAdd " + iAleph +
" + " + iBeth + " = " +
_object("MyFarm")._method("Add", "a" = iAleph,
"b" = iBeth));
xout("\r\nAdd " + iVal[0] +
" + " + iVal[1] + " = " +
_object("MyFarm")._method("Add", "a" = iVal[0],
"b" = iVal[1]));
xout("\r\nAdd 40 + 30 = " +
_object("MyFarm")._executeclass("XFa" +
"rm")::_method("Add", Left("atom", 1) = 40,
"b" = 30));
}