1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #include "stdafx.h"
- #include <stdlib.h>
- #include <stdio.h>
- #include <stddef.h>
- #ifdef _WIN32
- #include <windows.h>
- #endif //_WIN32
- struct IEntityFunction
- {
- virtual ~IEntityFunction()
- {
- printf("%s\n", __FUNCTION__);
- }
- virtual void f() = 0;
- };
- struct IEntityFunctionPrivilege
- {
- virtual ~IEntityFunctionPrivilege()
- {
- printf("%s\n", __FUNCTION__);
- }
- virtual void g() = 0;
- };
- struct SpEntity : public IEntityFunction
- {
- virtual ~SpEntity()
- {
- printf("%s\n", __FUNCTION__);
- }
- virtual void f()
- {
- printf("%s\n", __FUNCTION__);
- }
- };
- struct SpEntityPrivilege : public IEntityFunctionPrivilege, public SpEntity
- {
- virtual ~SpEntityPrivilege()
- {
- printf("%s\n", __FUNCTION__);
- }
- virtual void g()
- {
- printf("%s\n", __FUNCTION__);
- }
- };
- void test(IEntityFunction* pEntityFunction)
- {
- pEntityFunction->f();
- IEntityFunctionPrivilege *pEntityFunctionPrivilege = dynamic_cast<IEntityFunctionPrivilege*>(pEntityFunction);
- if (pEntityFunctionPrivilege)
- pEntityFunctionPrivilege->g();
- }
- int _tmain(int argc, TCHAR* argv[])
- {
- printf("\n SpEntityPrivilege:\n");
- IEntityFunction *pEntityFunction = new SpEntityPrivilege();
- test(pEntityFunction);
-
- delete pEntityFunction;
- printf("\n SpEntity:\n");
- pEntityFunction = new SpEntity();
- test(pEntityFunction);
- delete pEntityFunction;
- getchar();
- return 0;
- }
|