fig01_21.cpp
来自「数据结构与算法设计-C/C++描述两本书的所有示例程序标准代码。」· C++ 代码 · 共 38 行
CPP
38 行
class Employee
{
public:
void setValue( const string & n, double s )
{ name = n; salary = s; }
const string & getName( ) const
{ return name; }
void print( ostream & out ) const
{ out << name << " (" << salary << ")"; }
bool operator< ( const Employee & rhs ) const
{ return salary < rhs.salary; }
// Other general accessors and mutators, not shown
private:
string name;
double salary;
};
// Define an output operator for Employee
ostream & operator<< ( ostream & out, const Employee & rhs )
{
rhs.print( out );
return out;
}
int main( )
{
vector<Employee> v( 3 );
v[0].setValue( "George Bush", 400000.00 );
v[1].setValue( "Bill Gates", 2000000000.00 );
v[2].setValue( "Dr. Phil", 13000000.00 );
cout << findMax( v ) << endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?