C++: christmas present for your evil twin brother

C++ has great features. And dangerous ones. Consider this piece of code:

#include <iostream>

using namespace std;

#define sizeof(x) __LINE__*4

int main(void) {
    cout << sizeof(int) << endl;
    cout << sizeof(int) << endl;
}

This code is perfectly valid and prints 32 and 36. This error should be extremely hard to debug...

You may also like...

Leave a Reply

Your email address will not be published.