Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: wordsmithing

...

Code Block
bgColor#FFcccc
langcpp
// a.cpp
struct S {
  int a;
};
 
// b.cpp
class S {
public:
  int a;
};

Compliant Solution

The compliant solution correct mitigation depends on programmer intent. If the programmer intends for the same class definition to be visible in both translation units because of common usage, the solution is to use a header file to introduce the object into both translation units, as shown in this compliant solution:

...