正在加载图片...
Handle a type parameter u For a built-in and simple data type, there's almost no difference between by-value and by-reference in efficiency a For a class or complex data type, by-reference is usually used for efficiency But for type parameters of a template, we won't know in advance the real type it represents It is recommended declared them as const reference for the worst situation template typename elemtype> Binary Tree<elemtype>: find( const elemtype& value)Handle a type parameter ◼ For a built-in and simple data type, there’s almost no difference between by-value and by-reference in efficiency ◼ For a class or complex data type, by-reference is usually used for efficiency ◼ But for type parameters of a template, we won’t know in advance the real type it represents ◼ It is recommended declared them as const reference for the worst situation template < typename elemtype > BinaryTree<elemtype>::find(const elemtype& value) {};
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有