{"action":"opened","issue":{"url":"https://api.github.com/repos/pezy/CppPrimer/issues/67","repository_url":"https://api.github.com/repos/pezy/CppPrimer","labels_url":"https://api.github.com/repos/pezy/CppPrimer/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/pezy/CppPrimer/issues/67/comments","events_url":"https://api.github.com/repos/pezy/CppPrimer/issues/67/events","html_url":"https://github.com/pezy/CppPrimer/issues/67","id":168871352,"number":67,"title":"exercise 4.37 疑问","user":{"login":"SlothSimon","id":5823047,"avatar_url":"https://avatars.githubusercontent.com/u/5823047?v=3","gravatar_id":"","url":"https://api.github.com/users/SlothSimon","html_url":"https://github.com/SlothSimon","followers_url":"https://api.github.com/users/SlothSimon/followers","following_url":"https://api.github.com/users/SlothSimon/following{/other_user}","gists_url":"https://api.github.com/users/SlothSimon/gists{/gist_id}","starred_url":"https://api.github.com/users/SlothSimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SlothSimon/subscriptions","organizations_url":"https://api.github.com/users/SlothSimon/orgs","repos_url":"https://api.github.com/users/SlothSimon/repos","events_url":"https://api.github.com/users/SlothSimon/events{/privacy}","received_events_url":"https://api.github.com/users/SlothSimon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-02T12:20:14Z","updated_at":"2016-08-02T12:20:14Z","closed_at":null,"body":"给出的答案如下：\r\n    int i; double d; const string *ps; char *pc; void *pv;\r\n    pv = (void*)ps; // pv = const_cast<string*>(ps); or pv = static_cast<void*>(const_cast<string*>(ps));\r\n    i = int(*pc);   // i = static_cast<int>(*pc);\r\n    pv = &d;        // pv = static_cast<void*>(&d);\r\n    pc = (char*)pv; // pc = reinterpret_cast<char*>(pv);\r\n\r\n但自己看书理解后做题，第二行考虑到*pc和i一个是char一个是int，和reinterpret_cast部分的例子差不多，感觉应该用reinterpret_cast。\r\n而第四行考虑到是从pv的void*类型变到pc的char*类型，和static_cast给的第二个例子一样，感觉应该用static_cast。\r\n不知道我理解上是否有误？"}}
{"actor":{"display_login":"SlothSimon"}}