模板类tips

来源:互联网 发布:软件生存周期 过程 编辑:程序博客网 时间:2024/06/15 22:36
1 define template

eg:

template <typename T, int N>struct array_copy{    T values[N];};struct FieldEntry{    int index;    char name[32];    char defaultVal[128];};// FieldEntry is T; it is each element content/define// each element is  FieldEntry struct (it has 3 items)// MISC_CFG_COUNT is array element numberstatic array_copy<FieldEntry, MISC_CFG_COUNT> const s_miscCfgEntries ={    {        { MISC_CFG_GUID, "GUID", "e4e8aab7aa76da11b8b02bfd4d2338b7"},        { MISC_CFG_BROKER_IP, "BrokerIP", "127.0.0.1"},....}}

原创粉丝点击