Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

A simple(!) "Call by Value "Example

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9625
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)

 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic