2 Replies - 435 Views - Last Post: 06 April 2014 - 08:37 PM Rate Topic: -----

#1 gbcoder   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 11-December 13

How to call a class, within a class

Posted 06 April 2014 - 03:12 PM

How do you call a class within another class's methods?

My code keeps telling me its an error.

part of my code:

  } else { //bet is valid, moving on with the game
            ClassHand();
        }


Is This A Good Question/Topic? 0
  • +

Replies To: How to call a class, within a class

#2 Joshieboy2007   User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 148
  • Joined: 26-March 14

Re: How to call a class, within a class

Posted 06 April 2014 - 03:19 PM

Class.method(arguments); if I'm not mistaken
Was This Post Helpful? 1
  • +
  • -

#3 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11041
  • View blog
  • Posts: 18,857
  • Joined: 19-March 11

Re: How to call a class, within a class

Posted 06 April 2014 - 08:37 PM

What do you mean, "call a class"? You don't call a class, you call a method - specifically, you send a message to an object telling it to execute some method.

The suggestion above works for static methods, which do not depend on an instance of the class. For example, Math.pow(2,4) will produce the value 16. However, if the method is not static, then you need an instance of the class, and that instance probably needs some sort of state for the method call to be meaningful. (if the method does not depend on the instance's state, then there's no need for it to be an instance method, of course)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1