|
|
Home » Community » Newbie corner » Difficulty with Class declaration
Re: Difficulty with Class declaration [message #26093 is a reply to message #26092] |
Thu, 01 April 2010 00:57 |
brokndodge
Messages: 8 Registered: March 2010 Location: in front of my computer
|
Promising Member |
|
|
Quote: | 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.
|
think i got the circular dependency thing fixed. Thinking about it, main.h needs to know about Popups.h but Popups.h has no need to know main.h even exists. So first I try it your way:
in popups.h
#include "main.h"
// struct UDMS;
struct Popups : UDMS { //no difference in results whether
//": UDMS" is here or not
//stuff
};
and in main.h
// #include "popups.h"
// class Popups;
struct UDMS : TopWindow {
struct lilpop;
Popups lilpop;
//stuff
};
i get the following errors
popups.cpp
main.cpp
In file included from C:\MyApps\main\main.h:5,
from C:\MyApps\main\Popups.h:12,
from C:\MyApps\main\popups.cpp:1:
C:/upp/bazaar/TabBar/TabBarCtrl.h: In constructor `Upp::TabBarCtrl::Item::Item()':
C:/upp/bazaar/TabBar/TabBarCtrl.h:37: warning: converting of negative value `-0x000000001' to `Upp::dword'
In file included from C:\MyApps\main\Popups.h:12,
from C:\MyApps\main\popups.cpp:1:
C:\MyApps\main\main.h: At global scope:
C:\MyApps\main\main.h:21: error: `Popups' does not name a type
In file included from C:\MyApps\main\main.h:5,
from C:\MyApps\main\main.cpp:1:
C:/upp/bazaar/TabBar/TabBarCtrl.h: In constructor `Upp::TabBarCtrl::Item::Item()':
C:/upp/bazaar/TabBar/TabBarCtrl.h:37: warning: converting of negative value `-0x000000001' to `Upp::dword'
In file included from C:\MyApps\main\main.cpp:1:
C:\MyApps\main\main.h: At global scope:
C:\MyApps\main\main.h:21: error: `Popups' does not name a type
C:\MyApps\main\main.cpp: In member function `void UDMS::ProspectDetailTab()':
C:\MyApps\main\main.cpp:74: error: `lilpop' is not a member of `UDMS'
main: 2 file(s) built in (0:04.20), 2102 msecs / file, duration = 4328 msecs, parallelization 100%
There were errors. (0:04.64)
Then I follow my own logic and reverse that to:
in popups.h
//Popups.h doesn't really need to know about main.h
//so commented out this #include
//#include "main.h"
class Popups // compiler fusses about expecting a class-name
// before "{" if i use ": UDMS" in this example
{
// stuff
};
and in main.h
//main.h does need to know about Popups.h
#include "Popups.h"
struct UDMS : TopWindow {
struct lilpop;
Popups lilpop;
// stuff
};
i get the following
----- CtrlLib ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (1 / 10)
----- TabBar ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (2 / 10)
----- CtrlCore ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (3 / 10)
----- Draw ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (4 / 10)
----- plugin/bmp ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (5 / 10)
----- RichText ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (6 / 10)
----- Core ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (7 / 10)
----- plugin/z ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (8 / 10)
----- plugin/png ( GUI GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (9 / 10)
----- main ( GUI MAIN GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (10 / 10)
popups.cpp
main.cpp
In file included from C:\MyApps\main\main.h:5,
from C:\MyApps\main\main.cpp:1:
C:/upp/bazaar/TabBar/TabBarCtrl.h: In constructor `Upp::TabBarCtrl::Item::Item()':
C:/upp/bazaar/TabBar/TabBarCtrl.h:37: warning: converting of negative value `-0x000000001' to `Upp::dword'
C:\MyApps\main\main.cpp: In member function `void UDMS::ProspectDetailTab()':
C:\MyApps\main\main.cpp:74: error: ISO C++ forbids taking the address of a bound member function to form a po
inter to member function. Say `&Popups::QNHelpPopup'
main: 2 file(s) built in (0:05.19), 2596 msecs / file, duration = 5359 msecs, parallelization 100%
There were errors. (0:05.68)
now if i'm reading that correctly, it seems to be saying that i am simply calling Popups::QNHelpPopup incorrectly. The thing is I think it wants me to use a reference to Popups::QNHelpPopup rather than to call it directly, the whole reference thing is where I get completely lost.
Quote: | However I have seen that struct UDMS has a class Popups member and also class Popups is a subclass of UDMS. That sounds strange.
|
I think that is where my confusion lies. I don't understand the difference or which one I should be doing. I don't fully understand most of the Perl code I write either, but it works and I know that in this instance to get this result I can do this. Seems that with c++ I do need to fully understand it. Class member or subclass seems like splitting hairs to me. So maybe that is where the problem lies.
ps. Attached unmodified main.zip to my first post. thats the complete project nest from before i started tinkering with it based on cbpporter's guidance. attached new main.zip to this post that includes new changes.
-
Attachment: main_2.zip
(Size: 7.08KB, Downloaded 266 times)
[Updated on: Thu, 01 April 2010 01:53] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Jun 16 16:01:05 CEST 2024
Total time taken to generate the page: 0.02223 seconds
|
|
|