|
| |
#include "stdafx.h"
#include <iostream.h>
#pragma warning(disable:4786)
#include <map>
using namespace std;
template<class typeIndex, class typeNumber>
class CMyGenericContainer
{
public:
MyGenericContainer();
virtual typeNumber GetMinValue();
private:
map<typeIndex, typeNumber> m_mapMyValues;
};
template<class typeIndex, class typeNumber>
typeNumber CMyGenericContainer<typeIndex, typeNumber>::GetMinValue()
{
map<typeIndex, typeNumber>::iterator cur;
map<typeIndex, typeNumber>::iterator it;
// You may also use std::for_each() instead of the following.
for(it = m_mapMyValues.begin(); it != m_mapMyValues.end(); it++)
{
if(cur->second > it->second)
{
cur = it;
}
}
return cur->second;
}
|