CW4.1.6 for Hitachi SuperH - C++ Help

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

CW4.1.6 for Hitachi SuperH - C++ Help

ソリューションへジャンプ
2,188件の閲覧回数
eski
Contributor I

Hi,
I am using Codewarrior for Hitachi SuperH ver 4.1.6 build 0672.

I know it is an old version but i write software for casio machines and this is the one they use .

I face a problem with C++ syntax:
I do use delphi to write my software and i wrote a converter to convert pascal to C , everything works fine since years.
I face a problem with class method pointers , in delphi we can have variable which are class method pointers declared as " TOnClick = Procedure (Sender:TQtControl) of object;"
i translate this to :
typedef void (_tobject::*uonclick)(tqtcontrol *sender);
typedef struct {
_tobject *obj;
uonclick event;
}tonclick;

I do have declared class variable of that type
tonclick fonclick;

I do initialize the variable with
b->fonclick.obj=this;
b->fonclick.event=(uonclick)onlevelclick;

This declaration works fine with Visual C++ 6.0 but when i compile it with code warrior i get :
Warning : illegal implicit member pointer conversion
_qtcore.CPP line 1602 b->fonclick.event=(uonclick)onlevelclick;

--
Alban Edit: Mention product name in subject line.

Message Edited by Alban on 2007-03-20 05:48 PM

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,290件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee
One topic Lundins link does not mention is that pointer to members have a non intuitive conversion
behavior. With normal pointers, you can easily assign a pointer to a derived class to a pointer to the base class. With pointer to members its just the opposite. You can assign a pointer to a member of a base class to any pointer to member expecting a derived class, well, a bit hard to describe. In the end, a pointer to a member function can only point to any member function of the class it refers to, it is not possible to add new functions in derived classes and initialize the pointer to member with them (unless they overwriting a virtual function already existing in the base).

Daniel
See also:

http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/languag...

Message Edited by CompilerGuru on 2007-03-2106:09 PM

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,291件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee
One topic Lundins link does not mention is that pointer to members have a non intuitive conversion
behavior. With normal pointers, you can easily assign a pointer to a derived class to a pointer to the base class. With pointer to members its just the opposite. You can assign a pointer to a member of a base class to any pointer to member expecting a derived class, well, a bit hard to describe. In the end, a pointer to a member function can only point to any member function of the class it refers to, it is not possible to add new functions in derived classes and initialize the pointer to member with them (unless they overwriting a virtual function already existing in the base).

Daniel
See also:

http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/languag...

Message Edited by CompilerGuru on 2007-03-2106:09 PM

0 件の賞賛
返信
1,290件の閲覧回数
Lundin
Senior Contributor IV
You can't take the address from non-static member functions. Read all of this:

http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33
0 件の賞賛
返信