|
|
|
Макросы в роде DECLARE_...
|
|||
|---|---|---|---|
|
#18+
Где должны быть DECLATE_DYNAMIC и IMPLEMENT_DYNAMIC? И должны ли они присутствовать одновременно? А DECLARE_DYNACREATE и IMPLEMENT_DYNACREATE? И еще DECLARE_SERIAL и IMPLEMENT_SERIAL? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 12.05.2006, 21:33 |
|
||
|
Макросы в роде DECLARE_...
|
|||
|---|---|---|---|
|
#18+
Хмм , а точнее ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 12.05.2006, 23:21 |
|
||
|
Макросы в роде DECLARE_...
|
|||
|---|---|---|---|
|
#18+
13.1.1. What's the difference between IMPLEMENT_DYNAMIC, IMPLEMENT_DYNCREATE and IMPLEMENT_SERIAL? IMPLEMENT_DYNAMIC provides run time type information to support macros such as IsKindOf and GetRuntimeClass. IMPLEMENT_DYNCREATE adds the ability to allow MFC to create the type on the fly. This is required for any concrete data type that will be serialized to a file. IMPLEMENT_SERIAL also provides a version number for the class and adds the ability to use the >> operator to read the type from a file. As an example, if a derived class Dog uses IMPLEMENT_DYNCREATE and a base class Animal uses IMPLEMENT_SERIAL, then a Dog can be written with a pointer to either but can only be read by a pointer to Animal. MFC 3.x provides a constant called VERSIONABLE_SCHEMA to be used with IMPLEMENT_SERIAL to support multiple versions at the same time. The implementation in MFC is broken and fails at runtime. jimb@turningpoint.com, email, 7/11/95 [MFC 4.0 NOTE: It is not true that the versionable schema is broken anymore, and has been fixed in MFC 4.0. ] 13.1.2. How can I declare an abstract base class to be IMPLEMENT_SERIAL? You need a special form of IMPLEMENT_SERIAL that looks like this: Use the regular DECLARE_SERIAL but use IMPLEMENT_SERIAL_ABC shown below instead of IMPLEMENT_SERIAL. #define IMPLEMENT_SERIAL_ABC(class_name, base_class_name, wSchema) _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, NULL) CArchive& AFXAPI operator>>(CArchive& ar, class_name* &pOb) { pOb = (class_name*) ar.ReadObject(RUNTIME_CLASS(class_name)); return ar; } anonymous 13.1.3. I can't create an instance because of DECLARE_DYNCREATE! Question : ClassWizard generated a class for me but used DECLARE_DYNCREATE(...) and declared my constructor as protected. Now, when a try to create an instance of the class I get the compiler error: error C2248: 'CChkTbl::~CChkTbl' : cannot access protected member declared in class 'CChkTbl' Answer : ClassWizard does this because the framework normally handles instantiation for you. i.e. if this is a CView derived class, normally the CDocumentTemplate instantiates the view during the default OnFileNew(), or when you call CxxxDocTemplate->OpenDocumentFile() or something similar. The framework does this so that it will give you an error message if you accidentally try to instantiate it yourself. If you really need to do instantiation outside of the CDocTempate framework, simply change the constructor to be public. chucks@skypoint.com, programmer.tools, 8/12/95 Answer : The answer is that the DECLARE_DYNCREATE macro lays down a "protected:" directive and leaves it in place. One needs to make sure that anything following DECLARE_DYNCREATE should be "protected" too; if not, one needs to declare "public:" or "private:, as needed. duane@anasazi.com, email, 8/15/95 -------------------------------------------------------------- Don't worry - wear Huggies ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 15.05.2006, 09:25 |
|
||
|
|

start [/forum/topic.php?fid=57&fpage=355&tid=2031300]: |
0ms |
get settings: |
8ms |
get forum list: |
15ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
35ms |
get topic data: |
10ms |
get forum data: |
2ms |
get page messages: |
48ms |
get tp. blocked users: |
2ms |
| others: | 208ms |
| total: | 332ms |

| 0 / 0 |
