// 1. RPCMethodRegistry.h
typedef int (*RPCMethod)(CRPCParaPacker& packer);
class CRPCMethodEntry
{
public:
int id;
RPCMethod method;
};
class CRPCMethodRegistry
{
private:
CRPCMethodRegistry(void);
CRPCMethodRegistry(CRPCMethodRegistry const&); // No copy
constructor.
CRPCMethodRegistry& operator=(CRPCMethodRegistry const&); // No
assignment.
public:
static CRPCMethodRegistry& GetInstance(void);
virtual ~CRPCMethodRegistry(void);
public:
inline int RegisterMethod(const int nId, const RPCMethod pMethod);
RPCMethod GetMethod(const int nId);
private:
static CRPCMethodEntry entries[256];
static CRPCMethodRegistry instance;
};
// 2. RdbRegistry.h
class CRdbRegistry
{
public:
CRdbRegistry(void);
~CRdbRegistry(void);
public:
static int TestMethod1(CRPCParaPacker& packer);
static int TestMethod2(CRPCParaPacker& packer);
static int TestMethodN(CRPCParaPacker& packer);
};
// 3. RdbRegistry.cpp
CRdbRegistry::CRdbRegistry(void)
{
CRPCMethodRegistry& registry = CRPCMethodRegistry::GetInstance();
registry.RegisterMethod(0, TestMethod1);
registry.RegisterMethod(1, TestMethod2);
registry.RegisterMethod(2, TestMethodN);
}
VS2005 tells a link error, cannot resolute external symbol public: int
__thiscall CRPCMethodRegistry::RegisterMethod(int,int (__cdecl*const)
(class CRPCParaPacker &))" (?
RegisterMethod@CRPCMethodRegistry@@QAEHHQ6AHAAVCRP CParaPacker@@@Z@Z)
How to correct it?