Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A simple(!) "Call by Value "Example

 
Steve Jensen
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya folks.

OK, now i understand conceptually, what passing an argument by the "Call by Value" principle is.

But i've been looking at a small program from a book, which is meant to illustrate it. The code is below:-



I sort of understand how this program works, but i am well and truly stumped as to what the line......



......is doing.


What on earth is 'meth', i.e., this hasn't been declared anywhere else in the code!

Why is this so?

Any help would be greatly appreciated.

Cheers in advance

Steve
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


ob is an instance of class Test. Find where Test is declared and you should find a method named meth.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're missing the class Test (meth must be a method of this class)

If I'm reading what it's supposed to depict correctly, here's what would
go with it (and a bit extra, to see the difference)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic