views:

34

answers:

2

In the big picture I want to create a frame based application in Bada that has a single UI control - a label. So far so good, but I want it to display a number of my choosing and decrement it repeatedly every X seconds. The threading is fine (I think), but I can't pass the label pointer as a class variable.

//MyTask.h 
//...
result Construct(Label* pLabel, int seconds);
//...
Label* pLabel;

//MyTask.cpp
//...
result
MyTask::Construct(Label* pLabel, int seconds) {
 result r = E_SUCCESS;
 r = Thread::Construct(THREAD_TYPE_EVENT_DRIVEN);
 AppLog("I'm in da constructor");
 this->pLabel = pLabel;
 this->seconds = seconds;

 return r;
}
//...

bool
Threading::OnAppInitializing(AppRegistry& appRegistry)
{
// ...

    Label* pLabel = new Label();
 pLabel = static_cast<Label*>(pForm->GetControl(L"IDC_LABEL1"));
 MyTask* task = new MyTask();
 task->Construct(&pLabel); // HERE IS THE ERROR no matching for Label**
 task->Start();

// ...
}

The problem is that I have tried every possible combination of *, &, and just plain pLabel, known in Combinatorics...

It is not extremely important that I get this (it is just for training) but I am dying to understand how to solve the problem.

A: 

Have you tried:

task->Construct(pLabel, 0);

And by that I want to point out that you are missing the second parameter for MyTask::Construct.

MihaiD
A: 

No, I haven't. I don't know of a second parameter. But this problem is solved. If I declare a variable Object* __pVar, then the constructor should be Init(Object* pVar), and if I want to initialize an instance variable I should write

Object* pVar = new Object();
MyClass* mClass = new MyClass();
mClass->Construct(pVar);
Boris Rusev