###前提・実現したいこと
多次元配列(C++)
###発生している問題・エラーメッセージ
多次元配列の定義・宣言の仕方がいまいち理解できません。 以下のエラーがでます。 *** Break *** segmentation violation from libstdcxx.v6 import register_libstdcxx_printers from .printers import register_libstdcxx_printers ^
###該当のソースコード
1 void hoge(){ 2 double x[][3]; 3 x[0][0] = 100; 4 cout<< x[0][0] <<endl; 5 }
###試したこと
また、次のようにすればきちんと動作します。
1 void hoge(){ 2 double x[3][3]; 3 x[0][0] = 100; 4 cout<< x[0][0] <<endl; 5 }
一方、変数を配列の引数にすると・・・
1 void hoge(){ 2 int arrayX = 3; 3 double x[arrayX][3]; 4 x[0][0] = 100; 5 cout<< x[0][0] <<endl; 6 }
以下のエラーが出ます。
Error: Non-static-const variable in array dimension aidamacro/hoge.cc:3: (cint allows this only in interactive command and special form macro which is special extension. It is not allowed in source code. Please ignore subsequent errors.)
コンパイラのせいでしょうか?それとも文法が間違っているのでしょうか?
よろしくお願いします。
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/05/21 01:02