?? databasepointer.h
字號(hào):
// MUD Programming
// Ron Penton
// (C)2003
// DatabasePointer.h - A "smart" pointer class that looks up items in a database
//
//
#ifndef SIMPLEMUDDATABASEPOINTER_H
#define SIMPLEMUDDATABASEPOINTER_H
#include <iostream>
#include "Entity.h"
using std::ostream;
using std::istream;
// ======================================================
// This is the DATABASEPOINTER macro, which defines a
// database pointer proxy class. Why macros? Because
// I've learned that templates + circular dependencies
// are a VERY BAD combination when dealing with simple
// one pass compilers, like C++.
// ======================================================
#define DATABASEPOINTER( pt, t ) \
class t; \
class pt \
{ \
public: \
pt( entityid p_id = 0 ) \
: m_id( p_id ) {} \
\
pt& operator=( entityid p_id ) \
{ \
m_id = p_id; \
return *this; \
} \
\
operator entityid() \
{ \
return m_id; \
} \
\
t& operator*(); \
t* operator->(); \
operator t*(); \
\
entityid m_id; \
}; \
\
inline ostream& operator<<( ostream& s, const pt& p ) \
{ \
s << p.m_id; \
return s; \
} \
\
inline istream& operator>>( istream& s, pt& p ) \
{ \
s >> p.m_id; \
return s; \
}
namespace SimpleMUD
{
DATABASEPOINTER( player, Player )
DATABASEPOINTER( item, Item )
DATABASEPOINTER( room, Room )
} // end namespace SimpleMUD
#endif
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -