[英]C++. What is a subprogram and method?
I have a CPP HW to be done. 我要完成CPP硬件。 One question is: 一个问题是:
1) Write a subprogram (not a method) void promptForMovie(Movie & myMovie) that ..... 1)编写一个子程序(不是方法),其void ...提示
2) Write a method void output(ostream & out); 2)编写一个方法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. 这些不是C ++术语,因此您必须询问您的教授他或她对它们的含义。
In other OO languages, "method" typically means what C++ calls a "member function"; 在其他OO语言中,“方法”通常表示C ++所谓的“成员函数”。 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 这两个术语非常重叠,您需要与教授进行澄清,但这是定义它们的一种方式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.