Z
zouyongbin
Stanley B Lippman in his "C++ Primer" that a definition like this
should not appear in a header file:
int ix;
The inclusion of any of these definitions in two or more files of the
same program will result in a linker error complaining about multiple
definitions. So this kind of definition should be avoided as much as
possible. But as we know, the definition of a class is always in a
header file. And we can use "#ifndef" to eliminate the linker error
complaining about multiple definitions.
Do you agree with Mr Lippman? I thought that the definition of a object
is the same with the definition of a class for header files. Multiple
definitions will cause error for both of them.
should not appear in a header file:
int ix;
The inclusion of any of these definitions in two or more files of the
same program will result in a linker error complaining about multiple
definitions. So this kind of definition should be avoided as much as
possible. But as we know, the definition of a class is always in a
header file. And we can use "#ifndef" to eliminate the linker error
complaining about multiple definitions.
Do you agree with Mr Lippman? I thought that the definition of a object
is the same with the definition of a class for header files. Multiple
definitions will cause error for both of them.