views:

88

answers:

4

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

A: 

A method is another word for member function.

Maulrus
So `int main(int argc, char* argv) ...` is a method now?
JUST MY correct OPINION
method is a class or object function. So it is not another word for function. In practice methods are associated with OO, functions may not be.
mrjoltcola
... durrr, thanks for the correction. Edited.
Maulrus
+1  A: 

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.

mrjoltcola
+2  A: 

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.

janks
"Ask your professor to rephrase the question using normative terms." - or if he defines his terms in lectures, take better notes ;-)
Steve Jessop
A: 

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

  • Subprogram - Its part of your program which achieves a functionality for example a subprogram which stores the performes some computation on data. Now it is up to you how you define such a subprogram. You could implement it as a single monolitic function or a set of functions or maybe using classes.
  • Method - another name for a function
Yogesh Arora