C++ “我该如何解决?”;无法实例化抽象类";

C++ “我该如何解决?”;无法实例化抽象类";,c++,munin,C++,Munin,我正在尝试合并不同的分支以创建munin-node-win32的新版本 我目前正在努力使这把叉子工作。 但是我得到了以下错误 src\core\MuninPluginManager.cpp(135): error C2259: 'PerfCounterCustomMuninNodePlugin': cannot instantiate abstract class src\core\MuninPluginManager.cpp(135): note: due to following memb

我正在尝试合并不同的分支以创建munin-node-win32的新版本

我目前正在努力使这把叉子工作。

但是我得到了以下错误

src\core\MuninPluginManager.cpp(135): error C2259: 'PerfCounterCustomMuninNodePlugin': cannot instantiate abstract class
src\core\MuninPluginManager.cpp(135): note: due to following members:
src\core\MuninPluginManager.cpp(135): note: 'bool MuninNodePlugin::AutoConf(void)': is abstract
c:\users\username\projekte\munin-node-win3264\src\core\MuninNodePlugin.h(14): note: see declaration of 'MuninNodePlugin::AutoConf'
我认为这些是重要的代码片段

MuninNodePlugin.h

class MuninNodePlugin{
公众:
虚拟~MuninNodePlugin(){};
///此方法应始终是线程安全的
虚拟bool IsLoaded()=0;
///此方法也应始终是线程安全的
虚拟常量char*GetName()=0;
虚拟bool AutoConf()=0;
虚拟int GetConfig(char*buffer,int len)=0;
虚拟int GetValues(char*buffer,int len)=0;
虚拟布尔IsThreadSafe();
};
MuninPluginManager.cpp

//添加所有自定义插件
{
const char*perfPrefix=PerfCounterCustomMuninNodePlugin::SectionPrefix;
大小\u t perfPrefixLen=strlen(perfPrefix);
对于(size_t i=0;iIsLoaded()){
AddPlugin(插件);
}否则{
_Module.LogError(“未能加载自定义PerfCounter插件:[%s]”,keyName.c_str());
删除插件;
}
}
}
}
我对C++几乎一无所知,所以我不理解这个错误已经发布的解决方案。 我更喜欢像“改变这一行,它应该工作”这样的快速修复

奇怪的是,直接位于另一个块上方的代码不会抛出错误,即使它几乎完全相同/

//添加所有常规PerfCounter插件
{
const char*perfPrefix=PerfCounterMuninNodePlugin::SectionPrefix;
大小\u t perfPrefixLen=strlen(perfPrefix);
对于(size_t i=0;iIsLoaded()){
AddPlugin(插件);
}否则{
_Module.LogError(“未能加载PerfCounter插件:[%s]”,keyName.c_str());
删除插件;
}
}
}
}
PerfCounterCustomMuninNodePlugin.h

#pragma一次
#包括“core/MuninNodePlugin.h”
结构域{
std::字符串名;
std::字符串preParsedArgs;
//PerfCounter API参数
结构计数器{
std::字符串路径;
翻转手柄;
DWORD格式;
双重乘法;
}计数器;
};
类PerfCounterCustomMuninNodePlugin:public MuninNodePluginHelper
{
公众:
///\param sectionName此插件的INI文件节名
PerfCounterCustomMuninNodePlugin(常量std::string§ionName);
虚拟~PerfCounterCustomMuninNodePlugin();
虚拟int GetConfig(字符*缓冲区,int len);
虚拟int GetValues(字符*缓冲区,int len);
虚拟bool IsLoaded(){return m_Loaded;};
静态常量字符*节前缀;
私人:
bool OpenCounter();
布尔穆装载;
std::字符串m_SectionName;
HQUERY m_PerfQuery;
//所有字段都在这里表示
std::映射m_字段;
//预计算图形参数
std::字符串m_图形参数;
};

您似乎忘记在
perfcountCustomMuninnodePlugin
类中重写
AutoConf
。错误信息非常清楚。您可以发布PerfCounterCustomMuninNodePlugin的头文件吗?在GitHub repo中找不到它…我在第一篇文章中添加了头文件,谢谢。不幸的是,我无法重现此错误,因为我不知道我是如何遇到此问题的。所以我想我不再需要答案了。不过还是要谢谢你!