Tag Archives: Programming record

Error resolution: Error: redefinition of class xxx

Error: Redefinition of class XXX
Generally, an error redefinition of class XXX occurs, and there is also an error previous definition of class XXX
Erratum:
In general, the reason for the error is that #ifndef, #define, and #endif are not used in the header file (.h) of the class definition. In other words, there is no macro to prevent the class from being included multiple times.
Alternatively, you may have defined the class repeatedly, so take a closer look at your code to see if there are any duplicate definitions.
Modification:
Add macros for classes that prevent being included more than once:

#ifndef _BASESMOOTHINGALGORITHM_H_
#define _BASESMOOTHINGALGORITHM_H_

#include "BaseSmoothingAlgorithm.h"

#endif

Error: redefinition of class XXX

Error: redefinition of class XXX

error redefinition of class XXX ; meanwhile, error previous definition of class XXX

error:

generally, the error is caused by not using #ifndef, #define and #endif for protection in the header file (.h) of the class definition. In other words, there is no macro to prevent the class from being included multiple times.

or the class is defined repeatedly, so take a closer look at your code to see if it is defined repeatedly.

modification:

adds a macro to a class that prevents it from being included multiple times:

#ifndef _BASESMOOTHINGALGORITHM_H_
#define _BASESMOOTHINGALGORITHM_H_

#include "BaseSmoothingAlgorithm.h"

#endif