Register to reply

Simple Question about C++ classes

by failexam
Tags: classes, simple
Share this thread:
failexam
#1
Mar14-11, 03:32 AM
P: 339
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?
Phys.Org News Partner Science news on Phys.org
New type of solar concentrator desn't block the view
Researchers demonstrate ultra low-field nuclear magnetic resonance using Earth's magnetic field
Asian inventions dominate energy storage systems
Mark44
#2
Mar14-11, 10:26 AM
Mentor
P: 21,249
Quote Quote by failexam View Post
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?
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.


Register to reply

Related Discussions
Question on universailty classes Atomic, Solid State, Comp. Physics 3
Another terminology question. ZFC and classes. Set Theory, Logic, Probability, Statistics 8
Basic general ed classes before classes for 4 yr Bachelor's degree? Academic Guidance 5
Question on summer classes Academic Guidance 8
C++ question: nested classes Computing & Technology 5