Originally Posted by
Elysia
How do you figure?
Java
Code:
int cost(Oranges o, Apples a) {
if (o.paid == true || a.paid == true)
return;
else
o.paid = true; a.paid = true;
return o.cost() + a.cost();
}
C++
Code:
int cost(Oranges& o, Apples& a) {
if (o.paid == true || a.paid == true) {
return 0;
} else {
o.paid = true;
a.paid = true;
}
return o.cost() + a.cost();
}
An example how to use objects inside a function. You tell the newbie that, in C#, you just pass the objects, not needing to explain the difference of by value and by reference.
Now, the same example can be used to teach a higher-level newbie about the difference between passing an object by reference or by value.
You get my point. C++ illustrates better some things, C# some other.