Click here to Skip to main content
15,914,013 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalprinting data in PDF format Pin
Bombi22-Sep-03 19:30
Bombi22-Sep-03 19:30 
QuestionHow to draw a line with mouse? Pin
whiteclouds22-Sep-03 18:01
whiteclouds22-Sep-03 18:01 
AnswerRe: How to draw a line with mouse? Pin
Blake Coverett22-Sep-03 18:11
Blake Coverett22-Sep-03 18:11 
GeneralRe: How to draw a line with mouse? Pin
whiteclouds22-Sep-03 18:28
whiteclouds22-Sep-03 18:28 
GeneralRe: How to draw a line with mouse? Pin
Blake Coverett22-Sep-03 21:34
Blake Coverett22-Sep-03 21:34 
GeneralRe: How to draw a line with mouse? Pin
whiteclouds22-Sep-03 23:06
whiteclouds22-Sep-03 23:06 
GeneralRe: How to draw a line with mouse? Pin
Blake Coverett22-Sep-03 23:39
Blake Coverett22-Sep-03 23:39 
GeneralA ridiculous beginners question Pin
Terry O'Nolley22-Sep-03 17:23
Terry O'Nolley22-Sep-03 17:23 
I have laboriously coded around this little problem for years and I know that the solution is quite simple. But I am resistant to change and hate having to delve into documentation.

I am getting that "class already defined" error message when I include the same header file in more than 1 source file.

Here is what is happening:

ClassX - a user defined class
Window1 - the apps main window
Window2 - a modal dialog box invoked from Window1

Window1 has an instance of ClassX and so has "#include ClassX.h" in its header file (and won't compile without it of course)

Window2 has an instance of ClassX and so needs to "#include ClassX.h" in its header file

But it can't because it throws that error "C2011: 'ClassX' : 'class' type redefinition" error


Why is it that you can include headers like "afxdb.h" in a zillion files and not get this error?

If the compiler knows that the class is already defined, then why does it need the header file in both places?










GeneralRe: A ridiculous beginners question Pin
Nish Nishant22-Sep-03 17:39
sitebuilderNish Nishant22-Sep-03 17:39 
GeneralRe: A ridiculous beginners question Pin
Terry O'Nolley22-Sep-03 17:54
Terry O'Nolley22-Sep-03 17:54 
GeneralRe: A ridiculous beginners question Pin
Nish Nishant22-Sep-03 18:19
sitebuilderNish Nishant22-Sep-03 18:19 
GeneralRe: A ridiculous beginners question Pin
Terry O'Nolley22-Sep-03 19:15
Terry O'Nolley22-Sep-03 19:15 
GeneralRe: A ridiculous beginners question Pin
Nish Nishant22-Sep-03 19:17
sitebuilderNish Nishant22-Sep-03 19:17 
GeneralRe: A ridiculous beginners question Pin
Terry O'Nolley23-Sep-03 7:53
Terry O'Nolley23-Sep-03 7:53 
GeneralRe: A ridiculous beginners question Pin
Michael Dunn22-Sep-03 17:58
sitebuilderMichael Dunn22-Sep-03 17:58 
GeneralRe: A ridiculous beginners question Pin
Terry O'Nolley22-Sep-03 18:15
Terry O'Nolley22-Sep-03 18:15 
GeneralRe: A ridiculous beginners question Pin
Rick York22-Sep-03 18:26
mveRick York22-Sep-03 18:26 
GeneralRe: A ridiculous beginners question Pin
Alvaro Mendez23-Sep-03 4:22
Alvaro Mendez23-Sep-03 4:22 
GeneralRe: A ridiculous beginners question Pin
Rick York24-Sep-03 14:09
mveRick York24-Sep-03 14:09 
GeneralRe: A ridiculous beginners question Pin
John M. Drescher22-Sep-03 18:02
John M. Drescher22-Sep-03 18:02 
GeneralRe: A ridiculous beginners question Pin
Terry O'Nolley22-Sep-03 18:20
Terry O'Nolley22-Sep-03 18:20 
GeneralRe: A ridiculous beginners question Pin
John M. Drescher22-Sep-03 18:30
John M. Drescher22-Sep-03 18:30 
GeneralCallbacks Pin
halblonious22-Sep-03 16:50
halblonious22-Sep-03 16:50 
GeneralRe: Callbacks Pin
Phil Speller22-Sep-03 22:14
Phil Speller22-Sep-03 22:14 
GeneralRe: Callbacks Pin
halblonious23-Sep-03 11:35
halblonious23-Sep-03 11:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.