Void pointer values comparing C++
Posted
by
user2962977
on Stack Overflow
See other posts from Stack Overflow
or by user2962977
Published on 2013-11-07T02:10:16Z
Indexed on
2013/11/07
3:54 UTC
Read the original article
Hit count: 226
My actual question is it really possible to compare values contained in two void pointers, when you actually know that these values are the same type? For example int.
void compVoids(void *firstVal, void *secondVal){
if (firstVal < secondVal){
cout << "This will not make any sense as this will compare addresses, not values" << endl;
}
}
Actually I need to compare two void pointer values, while outside the function it is known that the type is int. I do not want to use comparison of int inside the function.
So this will not work for me as well: if (*(int*)firstVal > *(int*)secondVal)
Any suggestions?
Thank you very much for help!
© Stack Overflow or respective owner