错误:当调用协议缓冲区方法时,2个重载对此指针没有合法转换

时间:2015-06-09 11:23:15

标签: c++ protocol-buffers

在以下代码中调用C2663: MediaSetting::mutable_mediamessage: 2 overloads have no legal conversion for this pointer时,有人可以帮我解决此错误mutable_mediamessage()

class MediaSetting : public ::google::protobuf::Message {
 public:
  inline ::MSG::MediaMessage* mutable_mediamessage(int index);
  inline ::google::protobuf::RepeatedPtrField< ::MSG::MediaMessage >* mutable_mediamessage();
}

inline ::MSG::MediaMessage* MediaSetting::mutable_mediamessage(int index) {
  return mediamessage_.Mutable(index);
}

inline ::google::protobuf::RepeatedPtrField< ::MSG::MediaMessage >*
MediaSetting::mutable_mediamessage() {
  return &mediamessage_;
}

// my test codes
// ...
const ::MSG::MediaSetting& media = config.mediasetting();
::google::protobuf::RepeatedPtrField<::MSG::MediaMessage>* pmedia = media.mutable_mediamessage(); // Error C2663 is here

环境:VS2008

1 个答案:

答案 0 :(得分:1)

您正尝试通过const引用访问非const成员函数。