2021年3月14日星期日

c++ error: "error: use of deleted function"

Hello I was hoping someone could help me out with this error i was getting while writing c++ code. The header file titled Test_Wrapper.h has the following contents:

#include "OBSW_Wrapper.h"  using namespace OBSW_Wrapper;      class TestWrapper{      public:      OBSW_Wrapper::OBSW Target;      void SetMyTarget(OBSW_Wrapper::OBSW* OBSWptr);    };  

The cpp file has the following contents:

#include "Test_Wrapper.h"  using namespace OBSW_Wrapper;    void TestWrapper::SetMyTarget(OBSW_Wrapper::OBSW* OBSWptr){  this->Target = *OBSWptr;  }  

When i compile the code i get the following errors:

lib\lib_subfolder\Test_Wrapper.cpp:9:14: error: use of deleted function 'OBSW_Wrapper::OBSW& OBSW_Wrapper::OBSW::operator=(const OBSW_Wrapper::OBSW&)'   this->Target = *OBSWptr;                ^  lib\lib_subfolder\OBSW_Wrapper.h:22:8: note: 'OBSW_Wrapper::OBSW& OBSW_Wrapper::OBSW::operator=(const OBSW_Wrapper::OBSW&)' is implicitly deleted because the default definition would be   ill-formed:    class OBSW {          ^  

EDIT I have added the definition of the OBSW class which is located in OBSW_Wrapper.h

namespace OBSW_Wrapper  {      class OBSW {        public:          RT_MODEL_Subsystem_T Subsystem_M_;        RT_MODEL_Subsystem_T *const Subsystem_MPtr = &Subsystem_M_;// Real-time model        DW_Subsystem_T Subsystem_DW;    // Observable states        ExtU_Subsystem_T Subsystem_U;   // External inputs        ExtY_Subsystem_T Subsystem_Y;   // External outputs        RT_MODEL_Subsystem_T *const Subsystem_M = Subsystem_MPtr;            ExtU_Subsystem_T InputBuffer_U;          ExtY_Subsystem_T OutputBuffer_Y;          int Foo();        void Initialize_OBSW();          void Task_OBSW_Step();            static void run_OBSW_Step( void* pvParams ){      ((OBSW*)pvParams)->Task_OBSW_Step();      }          void SetInput1(real_T U1);          void GetOutput1(real_T* Y1);          void GetOutput2(real_T* Y2);      };    }  

Can anyone help me resolve these errors? Thank you.

https://stackoverflow.com/questions/66631101/c-error-error-use-of-deleted-function March 15, 2021 at 08:54AM

没有评论:

发表评论