Simple Question about C++ classes

  1. I have seen the following in a abook:

    "The argument(s) of a method can be any type of object (as long as its class has been made available to the program), as well as the predefined default types of variable. For example, methods in our three-vector class are not limited to just accepting arguments of type threevector, int, double, etc."

    I understand that the first statement is telling us that objects of all classes made available to the program can be used as arguments of a method.

    What I do not understand, however, is how the second statement follows logically from the first. "Methods in our three-vector class are not limited to just accepting arguments of type threevector, int, double, etc." Sure! No problem! But what other types of objects are you thinking of?
     
  2. jcsd
  3. Mark44

    Staff: Mentor

    The second sentence is saying that in addition to the built-in types (int, char, long, float, double, etc.) and types declared in the same class, objects of other classes can be used as parameters, as long as these other classes can be accessed by the class in which the method is defined.
     
Know someone interested in this topic? Share this thead via email, Google+, Twitter, or Facebook

Have something to add?