我们的导师要求我们浏览模板并解释它的各个部分:
Template<class T> set<T> set<T>:: setDifference(const Set<T> &that) const
这是我到目前为止所得到的:
Template<class T>: declares the new template
set<T>: states the return type of our template
set<T>: pretty confused about the second set, possibly the class name?
setDifference: Calls on our setDifference function
const Set<T> &that:
Parameters of setDifference, states set<T> cannot be modified within
setDifference or put on the left hand side of the equation. "&that" references "that"
memory location to use/call
const (at the end):
Our function can only be called by a const object of the class
nor can it call any non-const member functions or change member variables.
如果有人能够纠正/添加我已经拥有的东西,我将非常感激。
答案 0 :(得分:0)
这是在其类主体
之外定义成员函数setDifference的开始template <class T>
struct set{
//...
set setDifference( const set& that) const;
};
template<class T>
set<T> set<T>::setDifference( const set<T>& that) const
{
set<T> newInstance (...);
//implementation of setDifference: newInstance = this - that
return newInstance;
}
set<T>