Solved

error C2011: 'CDeta' : 'class' type redefinition

Posted on 2000-03-30
5
1,946 Views
Last Modified: 2007-10-18
I am getting following error while
Recompiling my project
ERROR:

f:\sagar\ch_ng_energy~\deta.h(6) : error C2011: 'CDeta' : 'class' type redefinition


I ckecked I haven't redefined its type
But still compiler is giving me such an error. can anybody will please tell me possible couses for this error AND how
 I can Remove this.

0
Comment
Question by:sag_kas
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
carldean earned 40 total points
ID: 2668579
This is often caused by multiple inclusion of the same header file.  Your compilation unit (cpp file) presumably includes the header that defines CDeta.  I expect that one of the other headers you are including also includes the file for CDeta.

This is a common problem for people who are fresh at C++.  What you need to do is include guards in every header file that prevent multiple inclusion.

I always put the following in

#ifndef __filename_goes_here_H
#define __filename_goes_here_H

// Contents of header file followed by

#endif

So if your CDeta class was defined in a file deta.h then you should use...

#ifndef __DETA_H
#define __DETA_H

class CDeta
{
};

#endif

The #ifndef .. #define should be the first thing in your file.  The #endif should be the last.

You also need to make sure that the __DETA_H bit is different in every header file (that's why I always use an uppercase version of the filename).

That should do the trick.
0
 

Author Comment

by:sag_kas
ID: 2707508
this answer solved my problem , i was also having same problem  with "CMSChart" I made the same changes suggested by you now it solved thaT problem too ,


     but when i run my s/w which makes use of "Microsoft Chart Control ver. 6.0"
     (which creates "mschart.h" file )

I am getting error dialog box ,as
   
       Debug assertion failed

      File : winocc.cpp
      Line :345

for information on how your program can cause an assertion failure see VC++ documentation on assert .

      Abort   Retry   ignore

when i clicks  "Retry" it comes to the window " this program has performed an illigal operation & closed down"
    and it closes the whole project.

will you please tell me why this happens

the changes i made in mschart.h
are

#ifndef __CMSChart_H
#define __CMSChart_H
......
file statments ...
......
#endif
     
   
0
 
LVL 1

Expert Comment

by:carldean
ID: 2707569
That's a very different problem I'm afraid.  The two aren't related.

What you need to do is...

A. Give me the points for getting the first question right!!! (Am I mercenary or what!)

B. Raise a new question regarding your assertion failure.  I'm afraid I've never used MSChart and as this question is now so old I don't think anybody else will be reading it.

Actually, a general word about assertions that are raised in Microsoft's code...  When the debugger allows you to debug the code you should always have a look at it, you never know the Microsoft chaps may have put a comment near the ASSERTion that give you an indication of why it has happened.

Cheers, Carl.

P.S. Make sure that your MSChart control is properly created and initialised before trying to do anything with it.
0
 

Author Comment

by:sag_kas
ID: 2708741
I solved that problem by myself ,
   cheers ,
thanks for your answer .
   
0
 
LVL 1

Expert Comment

by:carldean
ID: 2711175
FOUR points!!!!  Blimey I've just tought you an invaluable C++ lesson and all you dish out is a measly FOUR points.

I don't suppose there's much chance of getting a birthday card of you either!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
returning a dereferenced pts in C++ 10 142
Which IDE to use to begin C++ training? 5 59
Need some help with Microsoft Visual Studio C++ 2003 5 51
Dialogbox API leak? 18 81
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now