我正在尝试创建如下列表。但有错误。
#ifndef CLASS1_H
#define CLASS1_H
#include <list>
class class2
{
};
class class3
{
};
class class1
{
public:
typedef std::list<class2, class3*> m_list;
m_list mylist;
};
#endif
错误是:
In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/list:63:0,
from class1.h:3:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_list.h: In instantiation of ‘std::_List_base<class2, class3*>’:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_list.h:418:5: instantiated from ‘std::list<class2, class3*>’
class1.h:16:9: instantiated from here
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_list.h:294:9: error: ‘class3*’ is not a class, struct, or union type
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_list.h:296:60: error: ‘class3*’ is not a class, struct, or union type
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_list.h: In instantiation of ‘std::list<class2, class3*>’:
class1.h:16:9: instantiated from here
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_list.h:420:58: error: ‘class3*’ is not a class, struct, or union type
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_list.h:449:20: error: no members matching ‘std::list<class2, class3*>::_Base::_M_get_Tp_allocator’ in ‘class std::list<class2, class3*>::_Base’
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_list.h:450:20: error: no members matching ‘std::list<class2, class3*>::_Base::_M_get_Node_allocator’ in ‘class std::list<class2, class3*>::_Base’
请任何人知道这件事,请帮助我。