|
I don't know if I can meet your requirements, but the compilation is correct:
..........
///////////////////////////////////////////////////////// /////////////////////////
template <class T>
class CFieldType
{
public:
typedef map <string, CTypeObject <T> *> FieldTypeMap;
CFieldType () {}
~ CFieldType () {}
// template <class T>
void Register (string strFieldName, CTypeObject <T> * pTypeObject)
{
FieldTypeMap :: iterator itr = m_FieldTypeMap.find (strFieldName);
if (itr == m_FieldTypeMap.end ())
{
m_FieldTypeMap.insert (make_pair (strFieldName, pTypeObject));
}
}
void InitObject ()
{
for (FieldTypeMap :: iterator itr = m_FieldTypeMap.begin (); itr! = m_FieldTypeMap.end (); itr ++)
{
CTypeObject <T> * pTypeObject = itr-> second;
pTypeObject-> Init ();
}
}
private:
FieldTypeMap m_FieldTypeMap;
};
void main ()
{
CFieldType <string> sMap;
sMap.InitObject ();
string x ("X");
CStringObject * ps = new CStringObject (x);
sMap.Register (x, ps);
} |
|