【GUI】wxWidgets(旧wxWindows) その5【サイザー】 (960レス)
【GUI】wxWidgets(旧wxWindows) その5【サイザー】 http://mevius.5ch.net/test/read.cgi/tech/1270793556/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
レス栞
リロード規制
です。10分ほどで解除するので、
他のブラウザ
へ避難してください。
441: デフォルトの名無しさん [sage] 2012/07/14(土) 23:52:18.18 c++とwxWidgetsを勉強中です。 わからないことがあるので教えていただけませんか。 void functestFrame::OnButton2Click(wxCommandEvent& event) { wxString str1 = L"まっぎょ"; functestFrame::wxStringfunc(&str1); } void functestFrame::wxStringfunc(wxString* str) { wxMessageBox(*str);} 4-10はコンパイルと実行できました。 void functestFrame::OnButton3Click(wxCommandEvent& event) { wxArrayString temp1; temp1.Add(wxT("ぽけもん")); functestFrame::wxArrayStringfunc(&temp1); } void functestFrame::wxArrayStringfunc(wxArrayString *arraystring) { for (int i=0 ; i< *arraystring.GetCount() ; i++) {*arraystring.Item(i);} } コンパイルエラーがでます。 C:\Users\x\Desktop\functest\functestMain.cpp||In member function 'void functestFrame::wxArrayStringfunc(wxArrayString*)':| C:\Users\x\Desktop\functest\functestMain.cpp|169|error: request for member 'GetCount' in 'arraystring', which is of non-class type 'wxArrayString*'| C:\Users\x\Desktop\functest\functestMain.cpp|170|error: request for member 'Item' in 'arraystring', which is of non-class type 'wxArrayString*'| ||=== Build finished: 2 errors, 0 warnings (0 minutes, 1 seconds) ===| wxstringと同じ方法をしているつもりなのですが、どのようにすればコンパイルができるのでしょうか? http://mevius.5ch.net/test/read.cgi/tech/1270793556/441
442: デフォルトの名無しさん [sage] 2012/07/15(日) 11:07:19.04 >>441 ちょっとしたコードを書いてみた http://pastebin.com/KCE8eyDe コンパイルが通らない原因 wxArrayStringの通常変数とポインタ変数の違いがわかっていない C++では実体に対しては「.」でアクセス、ポインタ変数に対しては「->」アロー演算子でアクセスする 参考:http://brain.cc.kogakuin.ac.jp/~kanamaru/lecture/prog1/13-03.html × arraystring.GetCount(); ○ arraystring->GetCount(); あと関数の入り口で「wxArrayString *arraystring」と宣言されているならば その関数内部では「*arraystring」ではなく「arraystring」でアクセスする 「*」をつけてしまうと「arraystring」のポインタのポインタになってしまう void functestFrame::wxArrayStringfunc(wxArrayString *arraystring) { for (int i=0 ; i< *arraystring.GetCount() ; i++) {*arraystring.Item(i);} ← ここもいまいち何をしようとしてるかわからん } http://mevius.5ch.net/test/read.cgi/tech/1270793556/442
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.041s