-2
我想創建一個如下所示的列表。但有錯誤。錯誤,同時製作一個類和類指針的列表
#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’
請任何人知道對此,請幫助我。
你讀過列表文檔嗎? – Chethan 2013-05-02 04:02:07
是的,Chethan,我現在讀它...謝謝:) – suma 2013-05-02 04:07:31