私自身の構造を作成しようとしました。だから私はこのコードを書きました。C++構造体コンストラクタ
struct node
{
int val, id;
node(int init_val, int init_id)
{
val = init_val;
id = init_id;
}
};
node t[100];
int main()
{
...
}
私のプログラムをコンパイルしようとしました。
error: no matching function for call to 'node::node()'
note: candidates are:
note: node::node(int, int)
note: candidate expects 2 arguments, 0 provided
note: node::node(const node&)
note: candidate expects 1 argument, 0 provided
'node t [100];' default-constructは各要素ですが、 'node'にはデフォルトのコンストラクタがありません。 – 0x499602D2
可能な複製[型の配列を宣言するために型がデフォルトのコンストラクタを必要としますか?](http://stackoverflow.com/questions/2231414/does-a-type-require-a-default-constructor-in -order-to-it-array-of-it) – bames53