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.
nextを使って定数を変更できない理由を教えてください。
const int i = 10; int * p = reinterpret_cast<int *>(&i);
const_castconstness をキャストするために使用する必要がありますconst_cast。これは、この場合に特に適しています。
const_cast
constは定数を意味し、変更することはできません。int nonconst_i = const_cast<int>(i);その後、nonconst_iを使用できます
int nonconst_i = const_cast<int>(i);