Comparison between void pointers in C++

  c++, equals, pointers, void

What’s the size of the pointed memory by a void pointer?

In the example below, I’m comparing two void pointer that are pointing to the same "raw data" but with different type so different size…how it can works? Is it linked to the == operator?

#include <iostream>

using namespace std;

int main()
{
    char a = 'a';
    int b = 97;
    if ((void*)a == (void*)b){
        cout << sizeof(a) << sizeof(b) << endl;
    }
}

Source: Windows Questions C++

LEAVE A COMMENT