Click here to Skip to main content
16,006,512 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: newbie : why doesn't this work? plz plz plz Pin
davun8-Apr-02 8:34
davun8-Apr-02 8:34 
GeneralRe: newbie : why doesn't this work? plz plz plz Pin
lucy8-Apr-02 8:46
lucy8-Apr-02 8:46 
GeneralRe: newbie : why doesn't this work? plz plz plz Pin
8-Apr-02 8:47
suss8-Apr-02 8:47 
GeneralRe: newbie : why doesn't this work? plz plz plz Pin
davun8-Apr-02 9:24
davun8-Apr-02 9:24 
GeneralScrollWindowEx Problem! Pin
G.Richard8-Apr-02 5:43
G.Richard8-Apr-02 5:43 
GeneralRe: ScrollWindowEx Problem! Pin
alex.barylski8-Apr-02 7:22
alex.barylski8-Apr-02 7:22 
GeneralRe: ScrollWindowEx Problem! Pin
G.Richard9-Apr-02 3:36
G.Richard9-Apr-02 3:36 
GeneralHelp with multiple classes Pin
Xds8-Apr-02 5:32
Xds8-Apr-02 5:32 
Hi all,

This is my first post; I'm new to C++ so go easy on me.
I have two classes; and their functions include code that refer to the other:
i.e: Class X has code that uses a variable/function from Class Y and vice-versa. The classes are completely different, so it would not help to derive one off the other.

In Header.h:
------------------------------------------------------------
class X {
public:
	int  myint;
	void doit(void);
};

void X::doit(void) {
	printf("CY.myint = %i", CY.myint); // Print Class Y's myint
}


class Y {
public:
	int  myint;
	void doit(void);
};

void Y::doit(void) {
	printf("CX.myint = %i", CX.myint); // Print Class X's myint
}
------------------------------------------------------------

In Main.CPP:
------------------------------------------------------------
#include  "stdio.h"
#include "Header.h"

int main(void) {

	class X CX;
	class Y CY;

	CX.myint = 100;
	CY.myint = 200;
	CX.doit();
	CY.doit();

	return 1;

}
------------------------------------------------------------



How can I get these classes to work together?
I can't put an 'extern class Y' before the 'class X' declaration, so how can I let the compiler know that the other class exists and will be declared?

Thanks!

Mike
GeneralRe: Help with multiple classes Pin
Rickard Andersson208-Apr-02 5:39
Rickard Andersson208-Apr-02 5:39 
GeneralRe: Help with multiple classes Pin
Xds8-Apr-02 5:49
Xds8-Apr-02 5:49 
GeneralRe: Help with multiple classes Pin
Roger Allen8-Apr-02 6:09
Roger Allen8-Apr-02 6:09 
GeneralRe: Help with multiple classes Pin
Le centriste8-Apr-02 7:34
Le centriste8-Apr-02 7:34 
GeneralNeed a control to show .gif files Pin
Hans Ruck8-Apr-02 5:26
Hans Ruck8-Apr-02 5:26 
GeneralRe: Need a control to show .gif files Pin
Chris Losinger8-Apr-02 5:31
professionalChris Losinger8-Apr-02 5:31 
GeneralRe: Need a control to show .gif files Pin
Carlos Antollini8-Apr-02 5:39
Carlos Antollini8-Apr-02 5:39 
GeneralRe: Need a control to show .gif files Pin
Rickard Andersson208-Apr-02 5:41
Rickard Andersson208-Apr-02 5:41 
GeneralRe: Need a control to show .gif files Pin
Hans Ruck8-Apr-02 8:27
Hans Ruck8-Apr-02 8:27 
GeneralUsing Arabic Character in the MFC Pin
Mesut8-Apr-02 5:23
Mesut8-Apr-02 5:23 
GeneralRe: Using Arabic Character in the MFC Pin
Carlos Antollini8-Apr-02 5:43
Carlos Antollini8-Apr-02 5:43 
GeneralRe: Using Arabic Character in the MFC Pin
Carlos Antollini8-Apr-02 5:44
Carlos Antollini8-Apr-02 5:44 
Generalhelp Pin
8-Apr-02 3:41
suss8-Apr-02 3:41 
GeneralProblems with accessing a control from another class Pin
James P8-Apr-02 3:22
James P8-Apr-02 3:22 
GeneralRe: Problems with accessing a control from another class Pin
Mazdak8-Apr-02 4:06
Mazdak8-Apr-02 4:06 
GeneralRe: Problems with accessing a control from another class Pin
James P8-Apr-02 5:31
James P8-Apr-02 5:31 
GeneralRe: Problems with accessing a control from another class Pin
Mazdak8-Apr-02 6:02
Mazdak8-Apr-02 6:02 

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.