slide045.html
来自「《Big C++ 》Third Edition电子书和代码全集-Part1」· HTML 代码 · 共 49 行
HTML
49 行
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="blendTrans(Duration=2)" http-equiv="Page-Enter">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" src="./config.js"></script>
<script language="JavaScript" src="./pageFormat.js"></script>
<script><!-- // Set title on page
title()
//--></script>
</head>
<body>
<div onclick="document.location='slide046.html'">
<h2><font color="#009999">26.5.1 Function Objects (cont.)</font></h2>
<font size="+1">
<ul>
<li><tt>sort</tt> works on any type that has <tt>operator<</tt></li>
<li>Defined on strings, uses dictionary order</li>
<li>Consider sorting Employees:
<blockquote><tt>
<nobr>vector<Employee></nobr> staff;<br>
sort(<nobr>staff.begin(),</nobr> <nobr>staff.end()</nobr>);
</tt></blockquote>
</li>
<li>To sort by name, supply:
<blockquote>
<pre>bool operator<(const Employee& a, const Employee& b)
{
return a.get_name() < b.get_name();
}</pre>
</blockquote>
</li>
</ul>
</font>
<hr>
<center><small>
<a href='slide044.html'>prev</a>
|<a href='slide001.html'>top</a>
|<a href='slide046.html'>next</a>
</small></center>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?