w******g 发帖数: 67 | 1 I have a question about template typedef. The question is that I want to use
the data structure like map>.
So I define the following:
#ifndef DATATEMPLATE_H_
#define DATATEMPLATE_H_
#include |
B********e 发帖数: 1062 | 2 template
struct MapofVec{
typedef vector VecType;
typedef typename vector::iterator VecIter;
typedef map MapType;
typedef typename map::iterator MapIter;
};
use
**
【在 w******g 的大作中提到】 : I have a question about template typedef. The question is that I want to use : the data structure like map>. : So I define the following: : #ifndef DATATEMPLATE_H_ : #define DATATEMPLATE_H_ : #include
|
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 的大作中提到】 : template : struct MapofVec{ : typedef vector VecType; : typedef typename vector::iterator VecIter; : typedef map MapType; : typedef typename map::iterator MapIter; : }; : : use : **
|
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.
【在 w******g 的大作中提到】 : 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; : };
|