• Post Reply Bookmark Topic Watch Topic
  • New Topic

setters-getters 3 classes  RSS feed

 
jimme van der meer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is a basic question but I really struggle with this

First class:



Second Class:


Third class:



RESULT: 0

I know I make a new object in class A thats why the sysout returns 0. How can I make it so that I GET the value 2 instead of null in class A, and that I'm able to SET things in class B. So I stay at the same object so to say.

I just want to be able to SET things in class B and GET that same value from the setter-getter-class-C, in class A. Please help

Thanks in advance, Jimme
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Based on the code you posted, class A should not compile.

Henry
 
Norm Radder
Rancher
Posts: 2240
28
 
Campbell Ritchie
Marshal
Posts: 56521
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:. . . class A should not compile.  . . .
The solution is to create an instance method which you can refer to b from.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!