123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #include "stdafx.h"
- #include <stdlib.h>
- #include <stdio.h>
- #include <stddef.h>
- #include <windows.h>
- 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;
- }
|