Click here to Skip to main content
15,920,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Header files #include problem Pin
Oliver1233-Nov-07 13:58
Oliver1233-Nov-07 13:58 
GeneralRe: Header files #include problem Pin
Peter Weyzen3-Nov-07 19:13
Peter Weyzen3-Nov-07 19:13 
GeneralRe: Header files #include problem Pin
Vaclav_4-Nov-07 5:30
Vaclav_4-Nov-07 5:30 
GeneralRe: Header files #include problem Pin
Peter Weyzen4-Nov-07 6:36
Peter Weyzen4-Nov-07 6:36 
GeneralRe: Header files #include problem Pin
Bram van Kampen4-Nov-07 11:49
Bram van Kampen4-Nov-07 11:49 
GeneralRe: Header files #include problem Pin
Bram van Kampen4-Nov-07 11:11
Bram van Kampen4-Nov-07 11:11 
GeneralRe: Header files #include problem Pin
Oliver1234-Nov-07 11:33
Oliver1234-Nov-07 11:33 
GeneralRe: Header files #include problem Pin
Bram van Kampen4-Nov-07 12:17
Bram van Kampen4-Nov-07 12:17 
/////////////////////////////
// Header File X.H

#pragma once;
class Y; //Fwd Decl, Add by Hand
class X{
Y* m_pY;
};
////////////////////////////

////////////////////////////
// Header File Y.H

#pragma once;
class X;; //Fwd Decl, Add by Hand
class Y{
X* m_pX;
};
////////////////////////////

////////////////////////////
// Z.CPP
#include "stdafx.h"
#include "X.H"
#include "Y.H"


// Both Classes X and Y are properly declared here

////////////////////////////

This way things will work whatever the order of the includes. One of the Forwards will technically be redundant, in this example the forward 'class X' This does not matter, the compiler simply ignores redundant forwards.

Note however, that X.H and Y.H on their own are never usable. Sigh | :sigh: For this reason it is probably better to declare both classes in the same header. When you use ClassWizzard to create a new class, the wizzard gives default file names based on the class name. You can change these names, and can direct the generated file to any of your choice. And, Yes, you can direct more than one class definition to a single header file.

Hope this helps, Smile | :)



Bram van Kampen

GeneralRe: Header files #include problem Pin
Oliver1235-Nov-07 14:23
Oliver1235-Nov-07 14:23 
Question4 bit datatype? Pin
_NielsB3-Nov-07 8:56
_NielsB3-Nov-07 8:56 
AnswerRe: 4 bit datatype? Pin
David Crow3-Nov-07 11:55
David Crow3-Nov-07 11:55 
GeneralRe: 4 bit datatype? Pin
Bram van Kampen3-Nov-07 13:04
Bram van Kampen3-Nov-07 13:04 
QuestionChanging resource in a dll Pin
Imtiaz Murtaza3-Nov-07 8:14
Imtiaz Murtaza3-Nov-07 8:14 
AnswerRe: Changing resource in a dll Pin
Peter Weyzen3-Nov-07 18:58
Peter Weyzen3-Nov-07 18:58 
QuestionRemoving the scrollbars from a CFormView derived class Pin
Sternocera3-Nov-07 7:17
Sternocera3-Nov-07 7:17 
AnswerRe: Removing the scrollbars from a CFormView derived class Pin
Nelek4-Nov-07 21:36
protectorNelek4-Nov-07 21:36 
GeneralRe: Removing the scrollbars from a CFormView derived class Pin
Sternocera4-Nov-07 22:05
Sternocera4-Nov-07 22:05 
GeneralRe: Removing the scrollbars from a CFormView derived class Pin
Nelek4-Nov-07 23:48
protectorNelek4-Nov-07 23:48 
Questionflexgrid or any grid VC++ 2003 Pin
Rhymhoont3-Nov-07 6:30
Rhymhoont3-Nov-07 6:30 
QuestionTimer Triggers Pin
thes3cr3t13-Nov-07 4:56
thes3cr3t13-Nov-07 4:56 
AnswerRe: Timer Triggers Pin
Nelek7-Nov-07 4:01
protectorNelek7-Nov-07 4:01 
QuestionCreateProcess returns Error 1450 - No sufficient resources to complete requested service Pin
vipin_nvk3-Nov-07 4:52
vipin_nvk3-Nov-07 4:52 
AnswerRe: CreateProcess returns Error 1450 - No sufficient resources to complete requested service Pin
bob169723-Nov-07 6:40
bob169723-Nov-07 6:40 
Questioncan I Read multi keys from keyboard using Visual C++ 2005? Pin
allooba3-Nov-07 3:11
allooba3-Nov-07 3:11 
QuestionRe: can I Read multi keys from keyboard using Visual C++ 2005? Pin
David Crow3-Nov-07 3:42
David Crow3-Nov-07 3:42 

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.