[英]c++ double pointer? I don't know how to pronounce it
void* SendMsg(void* msg) {
char *result;
char tmpBuf[1000]={0};
message send_msg =*(message*)msg;//?
The problem is * and (*)type.问题是 * 和 (*) 类型。
*(message*)"parameterName";
how I can search it?我如何搜索它? what is that?那是什么?
"message" is custom made struct. “消息”是定制的结构。
The code is in C-style whwere a void pointer is passed to the function.代码是 C 风格的,其中将空指针传递给函数。 To use it it is cast in C-style to message* and immediately dereferenced (in this case assigned to a local variable named send_msg).为了使用它,它以 C 风格转换为 message* 并立即取消引用(在这种情况下分配给名为 send_msg 的局部变量)。
This code in C++ is technically known as a red herring for possible issues. C++ 中的这段代码在技术上被称为可能出现的问题的红鲱鱼。
In C++, I would expect a base-class (interface) as parameter or a template parameter.在 C++ 中,我希望基类(接口)作为参数或模板参数。
(message*)msg
says "pretend that msg
is a pointer to an object of type message
. message send_msg = *(message*)msg;
says "pretend that msg
is a pointer to an object of type message
and copy the message
object that it points at into send_msg
. (message*)msg
说“假装msg
是一个指向message
类型对象的指针message send_msg = *(message*)msg;
说”假装msg
是一个指向message
类型对象的指针并复制message
对象它指向send_msg
。 That will work fine if msg
in fact points at an object of type message
.如果msg
实际上指向message
类型的对象,那将工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.