| 发表于:2008-01-23 09:18:21 楼主 |
tempclass.h: #ifndef __tempclass_h__ #define __tempclass_h__ #if _msc_ver > 1000 #pragma once #endif // _msc_ver > 1000 #include <bitset> #include <vector> using namespace std; template <size_t _n> class ctempclass { typedef bitset <_n> bit; typedef vector <bit > vbit; typedef vector <vbit > vvbit; public: ctempclass(){} ~ctempclass(){} int and(vbit vb) { return 0; } int and(vvbit vvb) { return 0; } }; #endif // #ifndef __tempclass_h__ main.cpp: #pragma warning(disable:4786) #include "tempclass.h" int main() { vector <bitset <32> > vb; ctempclass <32> tc; tc.and(vb); return 0; } 错误如下: compiling... testbitset.cpp c:\documents and settings\dejing.yang\testbitset\tempclass.h(29) : error c2535: 'int __thiscall ctempclass <_n> ::and(class std::vector <class std::bitset <_n> ,class std::allocator <class std::bitset <_n> > > )' : member function already defined or declared c:\documents and settings\dejing.yang\testbitset\tempclass.h(24) : see declaration of 'and' c:\documents and settings\dejing.yang\testbitset\tempclass.h(32) : see reference to class template instantiation 'ctempclass <_n> ' being compiled error EXECuting cl.exe. testbitset.exe - 1 error(s), 0 warning(s) |
|
|
|
|