Compile Error : 'class' type redefinition 
Author Message
 Compile Error : 'class' type redefinition

Compile Error : 'class' type redefinition

I've got two classes derived from a common superclass. However when I
include headers for them both in another class I get a compile error
telling me that the superclass has been redefined:

dlg.h :

#include "ClassA.h"
#include "ClassB.h"

where ClassA : Public ClassBase
and ClassB : Public CLassBase

Compiler :

dlg.cpp
c:\dev\c++\lsc4\ClassBase.h(10) : error C2011: 'ClassBase' : 'class'
type redefinition

Beats me.

Simon Langdon



Tue, 30 Mar 2004 18:36:51 GMT  
 Compile Error : 'class' type redefinition
Hi,


Quote:
> Compile Error : 'class' type redefinition

> I've got two classes derived from a common superclass. However when I
> include headers for them both in another class I get a compile error
> telling me that the superclass has been redefined:

> dlg.h :

> #include "ClassA.h"
> #include "ClassB.h"

> where ClassA : Public ClassBase
> and ClassB : Public CLassBase

> Compiler :

> dlg.cpp
> c:\dev\c++\lsc4\ClassBase.h(10) : error C2011: 'ClassBase' : 'class'
> type redefinition

> Beats me.

> Simon Langdon

Try enclosing header contents between #if directives
#ifndef __HEADER_FILE_NAME_H
#define __HEADER_FILE_NAME_H
/*...declarations and stuff */
#endif

Thus you will ensure that your base class declaration will only get included
once in any "includer" file.
This is a general rule for header filez.

Regards,
Lucian



Tue, 30 Mar 2004 19:58:40 GMT  
 Compile Error : 'class' type redefinition

That works just fine, thanks

Simon.

On Fri, 12 Oct 2001 13:58:40 +0200, "Lucian Ion"

Quote:

>Hi,



>> Compile Error : 'class' type redefinition

>> I've got two classes derived from a common superclass. However when I
>> include headers for them both in another class I get a compile error
>> telling me that the superclass has been redefined:

>> dlg.h :

>> #include "ClassA.h"
>> #include "ClassB.h"

>> where ClassA : Public ClassBase
>> and ClassB : Public CLassBase

>> Compiler :

>> dlg.cpp
>> c:\dev\c++\lsc4\ClassBase.h(10) : error C2011: 'ClassBase' : 'class'
>> type redefinition

>> Beats me.

>> Simon Langdon

>Try enclosing header contents between #if directives
>#ifndef __HEADER_FILE_NAME_H
>#define __HEADER_FILE_NAME_H
>/*...declarations and stuff */
>#endif

>Thus you will ensure that your base class declaration will only get included
>once in any "includer" file.
>This is a general rule for header filez.

>Regards,
>Lucian



Tue, 30 Mar 2004 21:29:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. compile error ( 'struct' redefinition )

2. 'struct' type redefinition

3. 'struct' type redefinition

4. Please help with this error: 'CJob_List_Set' : 'class' type redefinition

5. Novice Q: error C2011: 'CXxxDoc' : 'class' type redefinition

6. error C2086: 'i' : redefinition

7. multiple #include's of a structure generates 'struct' type redefinition error

8. Newbie - Compile error (Cannot open include file: 'xmldom.idl': No such file or directory)

9. 'incompatble types error'- help needed

10. Runtime Error '13': Type Mismatch

11. Compiler error C2440: 'type cast'

12. error C2440: 'type cast' :

 

 
Powered by phpBB® Forum Software