c++ - Microsft Visual Studio C++ 2019 编译错误与 IMPLEMENT_DYNCREATE
问题描述
我正在开发一个需要运行多任务的程序,以便我可以运行一个计时器。
这是包含文件(MyRunTimers.h
):
#pragma once
#include <afxwin.h>
class MyRunTimers :
public CObject
{
int m_nNum;
bool m_bDone = FALSE;
CObject* m_pOwner = NULL;
bool m_bAutoDelete = FALSE;
void MyTimerThread();
public:
DECLARE_DYNAMIC(MyRunTimers)
protected:
MyRunTimers::MyRunTimers();
MyRunTimers::~MyRunTimers();
};
这是 cpp 文件(MyRunTimers.cpp
):
#include "pch.h"
#include "MyRunTimers.h"
IMPLEMENT_DYNCREATE(MyRunTimers, CObject)
MyRunTimers::MyRunTimers()
{
m_bDone = FALSE;
m_pOwner = NULL;
m_bAutoDelete = FALSE;
}
MyRunTimers::~MyRunTimers()
{
}
当我尝试编译时,IMPLEMENT_DYNCREATE
它以红色突出显示,我得到:
`E0135 - class "MyRunTimers" has no member "CreateObject"
解决方案
If you have DECLARE_DYNAMIC(MyClass)
in the class declaration (header file), then you need IMPLEMENT_DYNAMIC(MyClass, BaseClass)
in the definition file.
Alternatively, if you actually need IMPLEMENT_DYNCREATE()
, then you should have DECLARE_DYNCREATE()
in the class definition.
For a discussion about the differences, see here: Why should i use DECLARE_DYNAMIC instead of DECLARE_DYNCREATE?.
推荐阅读
- android - android联系人中的is_primary标志何时设置为非零值?
- c# - 母版页不会在 Web 窗体上显示其内容
- vue.js - Vue.js 和 VueRouter 性能缓慢
- spring-boot - 如果@Scheduled 注解的方法在两台不同的机器上运行,它会被调用两次吗?
- sql - json字段上的PosgtreSQL连接表
- mongodb - 日期标准不适用于使用spring数据的mongodb
- php - 写入 .csv 文件时 PHP 的编码问题
- flutter - 我们应该记住闭包吗?
- wordpress - 按角色向用户隐藏 Wordpress 类别
- google-chrome - 如何从电子应用程序调试“无法验证第一个证书”?