I have a CPP HW to be done. One question is:
1) Write a subprogram (not a method) void promptForMovie(Movie & myMovie) that .....
2) Write a method void output(ostream & out); that ....
My question is what exactly is a subprogram and a method? Which one of them means a function, and what does the other mean?
Thank you
Those aren't C++ terms, so you'll have to ask your professor what he or she means by them.
In other OO languages, "method" typically means what C++ calls a "member function"; that is, a function that is a member of a class, and is invoked on objects of that class. Constrast with a "free function", which, as the name implies, is a standalone function that is not a member of any class.
I suspect that your professor means "method" to mean "member function", and subprogram to mean just a regular free function. But who knows; I wouldn't bet my grades on it.
Ask your professor to rephrase the question using normative terms.
A subprogram is a simple, old-fashioned, non-object associated function.
A method is a member function (class or instance); part of a class. It must be called with either class scope or object scope.
方法是成员函数的另一种说法。
Both the terms are very overlapping and you need to clarify with your prof about them, but this is a way they can be defined
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.