关于c++Template的问题
----------------state.h--------------------
#ifndef STATE_H
#define STATE_H
#include"server.h"
template<class Type1,class Type2> class server;
template<class Type1,class Type2>
class state
{
public:
state(server<Type1,Type2> *){}
~state(){}
void init(){}
};
#endif
--------------server.h---------------------
#ifndef SERVER_H
#define SERVER_H
#include<string>
using std::string;
#include "state.h"
template<class Type1, class Type2> class state;
template<class Type1, class Type2>
class server:public Type1
{
friend class state<string,string>;
public:
server(Type2 *);
~server();
void init();
};
typedef server<string,string>
Service;
#endif
---------------main----------------------
#include<string>
using std::string;
#include "server.h"
void main()
{
string str="fsadfasdfsadfas";
Service * s=new Service(&str);
s->init();
}
------------------error------------------
Linking...
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall server<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::alloca
tor<char> > >::init(void)" (?init@?$server@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@@QAEXXZ)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall server<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<c
har> > >::server<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<c
har>,class std::allocator<char> > *)" (??0?$server@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@@QAE@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
Debug/template_test.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
-----------------------------------------
在VC6上编译通过,但是连接有错
怎么回事呢,模板高手指教