Help ! About Virtual Functions! | developer.brewmp.com Help ! About Virtual Functions! | developer.brewmp.com

Developer

Help ! About Virtual Functions!

Forums:

I have the following classes:

class Base
{

}

class BaseA : public Base
{
protected:
virtual void F()=0;
void FuncCallBack() { F(); };

class B : public BaseA
{
protected:
void F();

class C : public BaseA
{
B m_b;
protected:
void F() { F2() };
virtual void F2() = 0;

class D : public C
{
protected :
void F2();

D inst;

Now something happens:

in the instance m_b, the BaseA::FuncCallBack() has been called, It
called C::F(),
But in the instance inst,the BaseA::FuncCallBack() has been called, It
should called C::F(), But it does called into it! It just jumped over!
Then I press AVK_END, The handsets will be reseted!

But the codes works in the emuluator properly!

I don't know why . Please help me !

Do you catch call to pure virtual functions?
Basically, if it fails, it is because the current object when you call BaseA::F is recognized as a BaseA. Try first to remove all those protected and replace them by public. And ensure you are not using "this" before it is initialized:
if you do something like:
class A;
class B;
class A
{
public:
A( class B* b );
virtual void foo() = 0;
;
class B
{
public:
B();
void foo() { }
;
A::A( B *b) { b->foo(); }
B::B() : A( this /* this is a A */) { /*this is a B */}
This will obviously fail.
/kUfa

Do you catch call to pure virtual functions?
Basically, if it fails, it is because the current object when you call BaseA::F is recognized as a BaseA. Try first to remove all those protected and replace them by public. And ensure you are not using "this" before it is initialized:
if you do something like:
class A;
class B;
class A
{
public:
A( class B* b );
virtual void foo() = 0;
;
class B
{
public:
B();
void foo() { }
;
A::A( B *b) { b->foo(); }
B::B() : A( this /* this is a A */) { /*this is a B */}
This will obviously fail.
/kUfa

I just move all the virutal functions to the base class and then it
works!!! But I still don't know the reason. Because In the
simuluator , the origional code works properly.

I just move all the virutal functions to the base class and then it
works!!! But I still don't know the reason. Because In the
simuluator , the origional code works properly.

1)Certain features is not supported in Brew.
Like Virtual Functions,Global Variables,Floating Points & Statics.U need access them frm ur base class.
U will be getting an exact output in ur emulator,make sure u don't go on with that.

1)Certain features is not supported in Brew.
Like Virtual Functions,Global Variables,Floating Points & Statics.U need access them frm ur base class.
U will be getting an exact output in ur emulator,make sure u don't go on with that.

Quote:Like Virtual Functions,Global Variables,Floating Points & Statics.U need access them frm ur base class.
ARM C++ compiler completely supports virtual functions.
Floating point numbers can be used using BREW helper functions.
ruben

Quote:Like Virtual Functions,Global Variables,Floating Points & Statics.U need access them frm ur base class.
ARM C++ compiler completely supports virtual functions.
Floating point numbers can be used using BREW helper functions.
ruben