【发布时间】:2021-05-25 09:03:59
【问题描述】:
SoftwareDownload 是派生类。 从抽象类实现虚函数定义-da::skeleton::ServiceInterface_DMwithDASkeleton 请在下面找到代码。已编辑代码。 试图在派生类构造器中传递抽象类指针。
类 SoftwareDownload:public da::skeleton::ServiceInterface_DMwithDASkeleton { using DA_Skeleton= da::skeleton::ServiceInterface_DMwithDASkeleton;
protected:
da::skeleton::ServiceInterface_DMwithDASkeleton *DA_Skeleton_ptr;
public:
**SoftwareDownload**(da::skeleton::ServiceInterface_DMwithDASkeleton *DA_Skeleton_ptr ,ara::com::InstanceIdentifier instance_id ,ara::com::MethodCallProcessingMode mode);
virtual ~**SoftwareDownload**();
<ReturnType> **RequestToDownload**(const std::uint32_t& SID,const std::uint32_t& size)override;
<ReturnType> **TransferData**(const std::uint32_t& SID,const std::uint32_t& Payload_Data)override;
}
//SoftwareDownload Constructor . Trying to initialise abstract class pointer.
**SoftwareDownload**::**SoftwareDownload**(da::skeleton::ServiceInterface_DMwithDASkeleton *DA_Skeleton_ptr ,ara::com::InstanceIdentifier instance_id ,ara::com::MethodCallProcessingMode mode)
:**DA_Skeleton**(instance_id ,mode)
{
//Initialize SoftwareDownload Skeleton for service instance 1
**DA_Skeleton_ptr** = new DA_Skeleton(ara::com::InstanceIdentifier(1),ara::com::MethodCallProcessingMode::kEvent);
}
**SoftwareDownload**::~**SoftwareDownload**()=default;
//abstract Class
class **ServiceInterface_DMwithDASkeleton** : public da::ServiceInterface_DMwithDA, public ara::com::internal::skeleton::TypedServiceImplBase<ServiceInterface_DMwithDASkeleton> {
public:
**ServiceInterface_DMwithDASkeleton**(ara::com::InstanceIdentifier instance_id, ara::com::MethodCallProcessingMode mode = ara::com::MethodCallProcessingMode::kEvent) : ara::com::internal::skeleton::TypedServiceImplBase<ServiceInterface_DMwithDASkeleton>(instance_id, mode) {}
virtual ~**ServiceInterface_DMwithDASkeleton**()
{
//
}
**virtual** <ReturnType> **RequestToDownload**(const std::uint32_t& SID,const std::uint32_t& size) = 0;
**virtual** <ReturnType> **TransferData**(const std::uint32_t& SID,const std::uint32_t& Payload_Data) = 0;
【问题讨论】:
-
看起来您正在尝试实例化抽象类。
da::skeleton::ServiceInterface_DMwithDASkeleton某处。您包含的代码太少,我无法说出在哪里。请发帖minimal reproducible example -
@TedLyngmo 。请查找完整代码。
-
请发布真实代码。现在无法阅读或编译您在问题中提出的内容。创建minimal reproducible example。
-
我现在投票结束这个问题,因为你没有提供更多信息。
标签: c++ function class inheritance virtual