forked from Mooophy/Cpp-Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex11_19.cpp
38 lines (33 loc) · 782 Bytes
/
ex11_19.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! @Alan
//!
//! Exercise 11.19:
//! Define a variable that you initialize by calling begin() on the multiset
//! named bookstore from § 11.2.2 (p. 425). Write the variable’s type without
//! using auto or decltype.
//!
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <iterator>
class A
{
int lenth;
public:
int getLenth() const {return lenth;}
};
bool compareA(const A &a1, const A &a2)
{
return a1.getLenth() < a2.getLenth();
}
int main()
{
bool (*fp) (const A &a1, const A &a2) = compareA;
std::multiset<A, bool (*) (const A &, const A &)> m1(fp);
//! Exercise 11.19
std::multiset<A, bool(*) (const A &, const A &)>::iterator
begin = m1.begin();
return 0;
}