mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-03-19 19:35:17 +08:00
fix: add C-style cast for const pointer assignment
Fixes Light-City/CPlusPlusThings#362
This commit is contained in:
@@ -3,6 +3,6 @@ using namespace std;
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
const int p = 10;
|
const int p = 10;
|
||||||
const void *vp = &p;
|
// const void *vp = &p; // const pointer to const data
|
||||||
void *vp = &p; // error
|
void *vp = (void*)&p; // ✅ C-style cast
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ using namespace std;
|
|||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
const int p = 10;
|
const int p = 10;
|
||||||
const void *vp = &p;
|
// const void *vp = &p; // const pointer to const data
|
||||||
void *vp = &p; //error
|
void *vp = (void*)&p; // ✅ C-style cast
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user