Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 谷歌模拟:错误C2679:binary'=';:未找到接受类型为';的右操作数的运算符;常数A';_C++_Operator Overloading_Googlemock - Fatal编程技术网

C++ 谷歌模拟:错误C2679:binary'=';:未找到接受类型为';的右操作数的运算符;常数A';

C++ 谷歌模拟:错误C2679:binary'=';:未找到接受类型为';的右操作数的运算符;常数A';,c++,operator-overloading,googlemock,C++,Operator Overloading,Googlemock,尽管我使用“=”运算符重载了XYZMessage类,但在执行google模拟时,DGMessage类的编译错误如下: > t\debug\include\gmock\gmock-actions.h(813): error C2679: binary '=': > no operator found which takes a right-hand operand of type 'const A' > (or there is no acceptable conversion)

尽管我使用“=”运算符重载了XYZMessage类,但在执行google模拟时,DGMessage类的编译错误如下:

> t\debug\include\gmock\gmock-actions.h(813): error C2679: binary '=':
> no operator found which takes a right-hand operand of type 'const A'
> (or there is no acceptable conversion) 3>        with 3>        [ 3>  
> A=XYZMessage 3>        ] 3>c:\program files (x86)\windows
> kits\10\include\10.0.16299.0\shared\guiddef.h(27): note: could be
> '_GUID &_GUID::operator =(_GUID &&)' 3>c:\program files (x86)\windows
> kits\10\include\10.0.16299.0\shared\guiddef.h(27): note: or      
> '_GUID &_GUID::operator =(const _GUID &)'
> 3>c:\dg\git\sa3rdparty\crossplatform\googletest\out\googletest-release-1.8.0\windows\x86_64\msvc15.0\static_mt\debug\include\gmock\gmock-actions.h(813):
> note: while trying to match the argument list '(GUID, const A)' 3>    
> with 3>        [ 3>            A=XYZMessage 3>        ]
> 3>c:\dg\git\sa3rdparty\crossplatform\googletest\out\googletest-release-1.8.0\windows\x86_64\msvc15.0\static_mt\debug\include\gmock\gmock-actions.h(446):
> note: see reference to function template instantiation 'void
> testing::internal::SetArgumentPointeeAction<4,XYZMessage,false>::Perform<void,std::tuple<A1,A2,A3,A4,A5>>(const
> ArgumentTuple &) const' being compiled 3>        with 3>        [ 3>  
> A1=LPCTSTR, 3>            A2=XYZClientInternal *, 3>           
> A3=XYZMessage &, 3>            A4=XYZMessage &, 3>            A5=GUID *,
> 3>            ArgumentTuple=std::tuple<LPCTSTR ,XYZClientInternal
> *,XYZMessage &,XYZMessage &,_GUID *>

您能发布重载“=”运算符的声明吗?猜测:您的运算符接受对非常量的引用。添加一个异常的
常量
!另外,VTC uncomplete.updated重载“=”运算符产生错误的代码在哪里?我们知道了原因。这里,类成员变量之一是引用成员。
XYZMessage& operator=(const XYZMessage& m)  // Binary operator overloading func.
{
           
    m_header = m.m_header;
    m_items =  m.m_items;
            
    m_logger= m.m_logger;
    m_pMessageCrypto = m.m_pMessageCrypto;

    return *this;
}