我在尝试在类中创建对象时面临如何解决链接错误
I am facing while trying to create an object inside the class, How to resolve linking error?
示例代码:
ABC.h
Class ABC{
public:
ABC();
virtual bool a();
virtual bool b();
virtual bool c();
protected:
~ABC();
private:
BaseLM* m_lm;
}
abc.cpp
ABC::ABC()
{
#ifndef KASH
m_lm(new BaseLMD());
#else
m_lm(new BaseLMI());
#endif
}
我已经从BaseLM
BaseLMD
并BaseLMI
派生类,并尝试在abc.cpp
中创建对象收到错误:
错误 C2064:术语的计算结果不等于采用 1 个参数的函数
我希望根据类内部# define ifndef KASH
创建对象abc.cpp
请提出相同的解决方案。
我想你想使用初始值设定项列表。
ABC::ABC()
:
#ifndef KASH
m_lm(new BaseLMD())
#else
m_lm(new BaseLMI())
#endif
{
}
相关文章:
- 运行同一解决方案的另一个项目的项目
- Project Euler问题4的错误解决方案
- Ardunio UNO解决了多个重叠的定时器循环
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- 两个文件使用彼此的功能-如何解决
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 如何解决"invalid conversion from 'char' to 'const char*'"
- 在java中解决这段代码时面临循环中的问题
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 难以理解某些人解决IOI问题的源代码
- visual c++,如何获取解决方案目录中的代码
- 如何解决错误:SCIP C++中的 SCIP 阶段无效 <10>
- 节俭并发:未解决的外部问题
- IpOpt拒绝解决不受约束的问题
- 如何解决这个超硬恒星的创造问题
- 循环无限运行C++解决骑士之旅问题
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- C++Matching Brackets 2解决方案不起作用
- 在 ubuntu3 上C++ goto 定义有什么解决方案吗16.04?
- 为什么这段代码不起作用,我该如何解决?