Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在这个函数中:
int marshall_subscription (string sub, uint32_t sub_id, vector<u_int8_t> const & ser) { //Do something here to build serial_data *ser = serial_data; }
我得到错误:
error: no match for 'operator*' in '*ser'
这不是您通过引用传递 STL 的方式吗?
*ser = serial_data;
ser不是指针,它是引用,因此无需取消引用:
ser
ser = serial_data;
此外,ser被声明为const引用,因此分配给它会导致错误。要修复,请将其更改为非const参考:
const
int marshall_subscription(..., std::vector<u_int8_t>& ser);
ser不是指针,它是通过引用传递的值。因此,您不需要取消引用它。尝试: