c**********e 发帖数: 2007 | 1 typedef std::map MapType;
MapType theMap;
Referring to the code sample above, which one of the following blocks of
code displays the string contents of the entire map theMap?
a) MapType::iterator it = theMap.first();
while(it!= theMap.end()) std::cout << it;
b) MapType::iterator it = theMap.begin();
while(it!= theMap.end()) std::cout << theMap[it];
c) MapType::iterator it = theMap.begin();
while(it!= theMap.end()) std::cout << (*it++).second;
d) MapType::iterator it = theMap |
|
h**o 发帖数: 548 | 2 知道可以这样:
typedef map mapType;
mapType data;
data["FontSize"] = 10;
怎样实现这个那?
data["type1"]["FontSize"] = 10;
data["type2"]["FontSize"] = 4; |
|
w******g 发帖数: 67 | 3 Thanks a lot. Another question: if I want to define a function template to
print out the elements of the MapOfVec.
template
struct MapOfVec
{
typedef vector VecType;
typedef typename vector::iterator VecIter;
typedef map MapType;
typedef typename map::iterator MapIter;
};
template
void printElems_MapOfVec(const MapOfVec::MapType& map);
It a |
|
B********e 发帖数: 1062 | 4 This may work.
template
class MapOfVec{
public:
typedef vector VecType;
typedef typename vector::iterator VecIter;
typedef map MapType;
typedef typename map::iterator MapIter;
void print(MapType& map);
};
agian. |
|
|
|
|
|
|
|
|
B********e 发帖数: 1062 | 12 template
struct MapofVec{
typedef vector VecType;
typedef typename vector::iterator VecIter;
typedef map MapType;
typedef typename map::iterator MapIter;
};
use
** |
|