Несовместимость между кодом C и C ++

Данный код C

#include <stdio.h>
int x = 14; 
size_t check()
{
   struct x {};
   return sizeof(x); // which x
}
int main()
{
    printf("%zu",check()); 
    return 0;
}

дает 4 на выходе в C в моей 32-битной реализации, тогда как в C ++ код

#include <iostream>
int x = 14;    
size_t check()
{
   struct x {};
   return sizeof(x); // which x    
}
int main()
{
    std::cout<< check(); 
    return 0;
}

выводит 1. Почему такая разница?

17
задан Mohit Khullar 19 March 2011 в 08:39
поделиться