Home » Community » Newbie corner » Difficulty with Class declaration
Re: Difficulty with Class declaration [message #26091 is a reply to message #26090] |
Wed, 31 March 2010 21:56   |
cbpporter
Messages: 1427 Registered: September 2007
|
Ultimate Contributor |
|
|
Quote: |
Just like I said previously, I don't just want a solution. I need to understand the why and how. I am learning as fast as I can.
|
OK, I won't give you the solution then. But I hope I can help you find it.
I don't know if you are familiar with C++ build process. Every C++ (cpp) source file is compiled independently from each other and one result does not affect future results. When all files are compiled, all the results (object files) are linked together.
So "main.cpp" failed to compile. Let's see why.
On first line to have "#include "main/main.h"". When using include "" it will try to find the file relative to your folder, so I think that "#include "main.h"" would be better, especially if you want to move your packages around on disk. If you later change "main" folder to something else, you won't have to edit your sources.
So we are including "main.h", which includes <CtrlLib/CtrlLib.h> and #include <TabBar/TabBarCtrl.h>. Then you include <main/Popups.h>.
So let's see what Popups.h does. Well first in includes "main.h". But you are already including from main.h the file "popup.h", which tries to include "main.h". This is a harmless circular reference because of the include guards, but it can cause problems if previous headers do not have the necessary declarations. So your include line with "main.h" won't do anything.
Let's skip to the important part:
struct UDMS;
class Popups : UDMS
"struct UDMS" basically tell the compiler "hey, there is a structure, and it is called UDMS. I don't know anything about it, except it has a name and is a structure. Fell free to complain if someone tries to use it.". Then you try to define the class Popus, which inherits from UDMS, which at this point is not defined.
UDMS is declared in "main.h", but after you try to inherit from it in "popups.h".
So in main.h you should declare UDMS, in popups.h you should include main.h and then declare the Popups class.
I think this is getting long and confusing and I'll leave the first post at this stage. You should try to go line by line and see if everything is visible and declared before you try to use it and I await further questions.
|
|
|
Goto Forum:
Current Time: Thu Jul 03 02:53:01 CEST 2025
Total time taken to generate the page: 0.04436 seconds
|