friend Class Help
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
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.
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;
//Make WindowClass Obj to call WindowClass functions ect
//Array Offset counter
void WindowClass::Window(int 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???
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;
//Make TaskBarClass Obj to call TaskBar functions etc.
//Array Offset counter
void TaskBarClass::Add(int WinID)
//Window.cpp needs to call this when it creates a new window
void TaskBarClass::Minimize(int TaskBarID)
//minimize a window through taskbar right click menu
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
Code tags added by kermi3
I am posting this because you did not use code tags on this thread. In the furture please use Code Tags. They make your code MUCH easier to read and people will be much more likely to help you if you do. And they'll be happy about helping you ;)
Without code tags:
cout << "No code tags are bad";
With Code Tags:
This is of course a basic example...more complicated code is even easier to read with code tags than without.
cout << "This code is easy to read";
I've added code tags for you this time. They can be added by putting [code] at the beginning of your code and [/code] at the end. More information on code tags may be found at the link in my signature. I also suggest you take a look at the board guildlines if you have not done so already. Any further questions or ways I can help please feel free to PM me.
This is a common first post mistake, just remember to use [code] tags in the future and you'll get much more help.
Will remember to use the [code] tags in future....
Any help with my problem tho?