• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing Instance variables and Methods!  RSS feed

 
Ashwin Rao
Ranch Hand
Posts: 89
C++ Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following 2 classes:

How do i access the method set_a() (through the "address" in Person) from another class which contains main() ?
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You won't be able to, because address is declared private. You could add a public getter method for address in Person to make it accessible.
Try that first.
 
Ashwin Rao
Ranch Hand
Posts: 89
C++ Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. I didn't know about that [code] thingy!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!