Home » Community » Newbie corner » Problem using more classes...
Problem using more classes... [message #35645] |
Fri, 09 March 2012 17:18  |
idkfa46
Messages: 155 Registered: December 2011
|
Experienced Member |
|
|
Hello guys,
I am back looking for your help again...
I have some troubles calling back functions from different classes... here an example for an easier explanation:
main.cpp
#include "prova3.h"
prova3::prova3()
{
CtrlLayout(*this, "Window title");
x <<= THISBACK(a);
y <<= THISBACK(a);
x2 <<= THISBACK(b);
y2 <<= THISBACK(b);
}
void prova3::a()
{
if ( !x.IsNullInstance() && !y.IsNullInstance())
{
tot = prod(x,y);
}
else
{
tot = Null;
}
}
void prova3::b()
{
if ( !x2.IsNullInstance() && !y2.IsNullInstance())
{
tot2 = prova4::sum(x,y);
}
else
{
tot = Null;
}
}
int prova3::prod (int x, int y)
{
return x*y;
}
int prova4::sum (int x, int y)
{
return x+y;
}
GUI_APP_MAIN
{
prova3().Run();
}
prova3.h
#ifndef _prova3_prova3_h
#define _prova3_prova3_h
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define LAYOUTFILE <prova3/prova3.lay>
#include <CtrlCore/lay.h>
class prova3 : public Withprova3Layout<TopWindow> {
public:
void a();
void b();
int prod (int x, int y);
typedef prova3 CLASSNAME;
prova3();
};
class prova4 {
public:
int sum (int x, int y);
};
#endif
prova3.lay
LAYOUT(prova3Layout, 403, 257)
ITEM(EditInt, y, LeftPosZ(45, 64).TopPosZ(92, 19))
ITEM(EditInt, y2, LeftPosZ(161, 64).TopPosZ(92, 19))
ITEM(EditInt, x, LeftPosZ(47, 64).TopPosZ(57, 19))
ITEM(EditInt, x2, LeftPosZ(161, 64).TopPosZ(57, 19))
ITEM(Label, dv___4, SetLabel(t_("x")).LeftPosZ(10, 33).TopPosZ(57, 21))
ITEM(Label, dv___5, SetLabel(t_("y")).LeftPosZ(10, 33).TopPosZ(92, 21))
ITEM(EditInt, tot, LeftPosZ(47, 64).TopPosZ(130, 19))
ITEM(EditInt, tot2, LeftPosZ(160, 64).TopPosZ(130, 19))
END_LAYOUT
calling function prod() from the same class (prova3) there are no problems but if i try to call back sum(x,y) from a different class (prova4) i receive the following error:
'prova4::sum' : illegal call of non-static member function
c:\myapps\prova3\prova3.h(28) : see declaration of 'prova4::sum'
Where I'm wrong today ?!
Regards,
Matteo
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 15:04:07 CEST 2025
Total time taken to generate the page: 0.02955 seconds
|