Hi
Im making a gui, in c\c++ mixed (hehe).
The problem m having is i need to call a function from another class before that class is actually defined.
My WindowClass is defined first and needs to call TaskBarObj.Add(WinID) from the TaskBarClass which is defined AFTER the WindowClass.
eg...very cut down and off the top of my head
Code:
//window.cpp
class WindowClass
{
private:
int WinID;
public:
WindowClass(){};
~WindowClass();
void Window(int WinID); //Constructor
void Close(int WinID);
void Minimize(int WinID);
void Maximize(int WinID);
};
//make pointer to 100 WindowClass obj on free store
WindowClass *WinArray=new WindowClass[100];
//Make WindowClass Obj to call WindowClass functions ect
WindowClass WindowObj;
//Array Offset counter
int WinCounter=-1;
void WindowClass::Window(int WinID)
{
WinCounter++;
WinArray[WinCounter].WinID=WinID;
//needs to call TaskBar Class TaskbarObj.Add(WinID);
//But it has not been defined ....will making TaskBask a frined class enable it to call a undefined function???
}
//TaskBar.cpp
class TaskBarClass
{
private:
int TaskBarID
public:
TaskBarClass(){};
~TaskBarClass();
void Add(int WinID);
void Close(int TaskBarID);
void Minimize(int TaskBarID);
void Maximize(int TaskBarID);
};
//Make pointer to 100 TaskBarClass Objs on free store
TaskBarClass *TaskBarArray=new TaskBarClass[100];
//Make TaskBarClass Obj to call TaskBar functions etc.
TaskBarClass TaskBarObj;
//Array Offset counter
int TaskBarCounter=-1;
void TaskBarClass::Add(int WinID)
{
//Window.cpp needs to call this when it creates a new window
TaskBarCounter++;
TaskBarArray[TaskBarCounter].TaskBarID=WinID;
}
void TaskBarClass::Minimize(int TaskBarID)
{
//minimize a window through taskbar right click menu
WindowObj.Minimize(TaskBarID);
}
So the problem is that i can declare one class, then the second class, but the first class wont be able to call functions in the second class because it was defined first.
will making taskbarclass a frined of windowclass allow me to call a a taskbarclass function within windowclass, before the taskbarclass is actually defined???
can anyone help??
plz email me as i dont know when i will be able to check this board again.....if you need source plz ask and i will send you the two seperate cpp class files
email: [email protected]
Thx.....
Code tags added by kermi3