|
|
Home » Community » Newbie corner » Difficulty with Class declaration
Difficulty with Class declaration [message #26090] |
Wed, 31 March 2010 18:25 |
brokndodge
Messages: 8 Registered: March 2010 Location: in front of my computer
|
Promising Member |
|
|
I am experienced with GTK-Perl and of course Bash scripting, but those languages simply are not suited for the project I am working on now. I figured since it only took two days to learn perl - I could handle C++ with the help of UPP. Class is giving me some difficulty tho. I can run everything inline, but that would make for a very difficult to maintain source tree. I am trying to break the entire project up into classes for easier maintenance.
My difficulty is in trying to call a member function of a derived class from the base class. I have reviewed various example's and read every resource I can find on classes, references and pointers. I simply do not understand references and pointers.
My first test case is a simple call to a help window. I know there is probably a better way to display a help window, there is a method to my madness here in that I am trying to understand HOW to call a member of a derived class. Most of the functionality of my project will be in these derived classes with only the parent gui being in the base class. I am getting compile errors talking about non-class types and other such with every test I run. I'm not just looking for the answer, I need to understand the why and how of it.
Here is what I'm working with:
main.h
#ifndef _main_main_h_
#define _main_main_h_
#include <CtrlLib/CtrlLib.h>
#include <TabBar/TabBarCtrl.h>
// included Popups.h for complete definition of
// derived class Popups
#include <main/Popups.h>
using namespace Upp;
#define LAYOUTFILE <main/main.lay>
#include <CtrlCore/lay.h>
//forward declaration of derived class
class Popups;
// UDMS is my base class
struct UDMS : TopWindow {
private:
Popups lilpop;
void ProspectDetailTab(void);
public:
typedef UDMS CLASSNAME;
UDMS();
};
#endif //#define _main_main_h_
Popups.h
#ifndef _main_popups_h_
#define _main_popups_h_
#include <main/main.h>
using namespace Upp;
#define LAYOUTFILE <main/popups.lay>
#include <CtrlCore/lay.h>
struct UDMS;
class Popups : UDMS
{
private:
WithQNHelpLayout<ParentCtrl> qnhelp;
void close();
public:
typedef Popups CLASSNAME;
Popups();
//core gui's
//prospect gui's
void QNHelpPopup(void);
};
#endif //#define _main_popups_h_
main.cpp
#include "main/main.h"
// ommitted 99% of app code to just
//include the offending function here.
void UDMS::ProspectDetailTab(void)
{
struct lilpop;
Popups lilpop;
detail.QNHelpButton.WhenAction = THISBACK(lilpop.QNHelpPopup);
};
Popups.cpp
#include "main/Popups.h"
Popups::Popups()
{ ////Title("Unified Dealer Management System").Sizeable();
//AddFrame(menu);
//CtrlLayout(*this, "Unified Dealer Management System");
CtrlLayout(qnhelp);
};
// this is the member of derived class Popups i'm trying to call
void Popups::QNHelpPopup(void)
{
CtrlLayout(qnhelp);
qnhelp.QNHelpText.SetText(" CCI - Customer Called IN \n"
" RMC - Returned my Call \n"
" NA - No Answer \n"
"DC1,2,3,w - Phone 1,2,3,work Disconnected \n"
"LM1,2,3,w - Left Message on phone 1,2,3,work \n"
"APPT - Set Appointment (open appointment popup) \n"
" AC - Appointment Confirmed \n"
" NS - Didn't Show for Appointment \n"
"KEPT - Kept Appointment \n"
" NN - Enter New Note \n"
"Find - Open Find Prospect Popup");
qnhelp.DoneButton.WhenAction = THISBACK(close);
};
void Popups::close(void) {
delete this;
};
errors from mingw when I execute with ctrl+f5
popups.cpp
main.cpp
In file included from C:/MyApps/main/main.h:5,
from C:/MyApps/main/Popups.h:4,
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:4,
from C:\MyApps\main\popups.cpp:1:
C:/MyApps/main/main.h: At global scope:
C:/MyApps/main/main.h:19: error: field `lilpop' has incomplete 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.h:6,
from C:\MyApps\main\main.cpp:1:
C:/MyApps/main/Popups.h: At global scope:
C:/MyApps/main/Popups.h:13: error: expected class-name before '{' token
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:04.54), 2274 msecs / file, duration = 4688 msecs, parallelization 100%
There were errors. (0:05.03)
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.
-
Attachment: main.zip
(Size: 7.07KB, Downloaded 259 times)
[Updated on: Wed, 31 March 2010 23:40] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri May 10 06:51:44 CEST 2024
Total time taken to generate the page: 0.01936 seconds
|
|
|