There is this code:
a.hpp file:
class A;
file a.cpp:
file main.cpp:
#include "a.hpp"
So, class A
is defined both in the main.cpp and a.cpp files , and there are also two objects of these classes defined in each translation unit. The definition in both Class A
translation units is different, but this code compiles. However, one definition rule says that a program can have many type definitions (but only one in each translation unit), and these definitions must be the same. So why is this code compiled even if the definition of class A
is different in both files?
scdmb source share