Home  >  Q&A  >  body text

I don’t understand a sentence in c++.

std::string data = "username=15111651349&password=qq1990086708&client=wap";

const void *ss = (const char *)data.c_str();

bResults = WinHttpSendRequest(hRequest, 0, 0, const_cast<void *>(ss), data.length(),
data.length(), 0);

const_cast<void *>(ss) I don’t understand this sentence

阿神阿神2648 days ago849

reply all(2)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-06-22 11:55:34

    :const_cast<type_id> (expression)
    This operator is used to modify the const or volatile attribute of the type. Except for the const or volatile modification, the types of type_id and expression are the same.
    1. The constant pointer is converted into a non-const pointer, and still points to the original object;
    2. The constant reference is converted into a non-const reference, and still points to the original object;
    3. const_cast is generally used to modify the bottom pointer . Such as const char *p form.

    reply
    0
  • 天蓬老师

    天蓬老师2017-06-22 11:55:34

    This performs an operation that can be dangerous if you don't know what you are doing. This keyword removes the constqualifier

    from the variable.

    reply
    0
  • Cancelreply