If you are using a C ++ program and the header file includes class definitions, the class definitions must exactly match those used for the initial assembly of the file. This is one rule of definition . If your professor has deleted private variable declarations from class definitions, you are likely to run into crashes; this is because your different .o files will not agree with the size of the objects defined by these classes.
If your professor wants to hide the implementation of the class, he should use the p / impl pattern . If you want to use the header file, you must completely remove the class definitions that are defined and not try to use them (you can use the direct definition, as in class Foo;
to satisfy any functions that accept / return the class as a pointer parameter, however).
source share