The next two statements in main() call the member function setdata():
s1.set data(1066);
s2.set data(1776);
These statements don’t look like normal function calls. Why are the object names s1 and s2 connected to the function names with a period? This strange syntax is used to call a member function that is associated with a specific object. Because set data() is a member function of the small obj class, it must always be called in connection with an object of this class. It doesn’t make sense to say
set data(1066);
Thursday, October 16, 2008
Calling Member Functions
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment