Hi,
I have been exploring doing some GUI programming with the wxWidgets toolkit as i am used to that from programming wxPython in python. I am doing the tutorials from zetcode and i am very mystified. (i think i spelt that wrong). This is the url http://zetcode.com/tutorials/wxwidgetstutorial/menustoolbars/ Its the first one on the page.

The issue i am having difficulty grasping is to do with the way that menu.h and menu.cpp work together because nothing ever seems to ever deal with menu.cpp yet it still defines the constructor and other functions. My questions is, how does it know to go to that file for the constructor? Or is that just all done when compiling, im just really confused as to why nothing is getting done to menu.cpp, its all menu.h that is getting included.

Cheers

That's because you're including the file "menu.h" ...
In 'menu.h' the whole class is declared so the compiler knows about it ...

BTW, While compiling the compiler will put all these files together to one file: the object file ...

So does that mean if i renamed the cpp file something apart from menu.cpp it wouldnt work or am i completley on the wrong foot here?

So does that mean if i renamed the cpp file something apart from menu.cpp it wouldnt work or am i completley on the wrong foot here?

No, it should also work if you rename 'menu.cpp' to something else ...
:)

You can try it !

That's because you're including the file "menu.h" ...
In 'menu.h' the whole class is declared so the compiler knows about it ...

BTW, While compiling the compiler will put all these files together to one file: the object file ...

Ah i didnt see that one file, so basically the compiler notices that I use the class as a sort of abstract class. Then it makes it into one object and when you call SimpleMenu from menu.h SimpleMenu has all the attributes that menu.cpp made for it.

I hope that right. :)

Ah i didnt see that one file, so basically the compiler notices that I use the class as a sort of abstract class. Then it makes it into one object and when you call SimpleMenu from menu.h SimpleMenu has all the attributes that menu.cpp made for it.

I hope that right. :)

Yup, in the file 'menu.cpp' in the constructor of class 'SimpleMenu' you're setting all the attributes you want your menu to have ...

Edit:: In menu.h you aren't calling the class 'SimpleMenu', you're only declaring it ...

Comments
Cheers, a little bit closer to understanding :)

Yeah cheers, i think i get it all now. A little weird to bend my head around but ill get there. Thanks for your help.

This question has already been answered. Start a new discussion instead.