こんにちは、配列に保存される関数に 10 個の引数を渡したいと思います。
function( 4, 3, 5); //calling function and passing arguments to it.
void function(int array[10])
{
cout<<array[0]; // = 4
cout<<array[1]; // = 3
cout<<array[2]; // = 5
cout<<array[3]; // = NULL or 0 or sth else
}
基本的には、好きなだけ多くの引数を渡す機会が必要です。それ以上でもそれ以下でもありません。
こんなはずない。
function( 4, 3, 5); //calling function and passing arguments to it.
void function(int x1=NULL , int x2=NULL , int x3=NULL ,int x4=NULL , int x5=NULL)
{
for (int i=0 ; i<10;i++)
{
array[i] = x1; // x2 , x3 and so on ...
}
cout<<array[0]; // = 4
cout<<array[1]; // = 3
cout<<array[2]; // = 5
cout<<array[3]; // = NULL or 0 or sth else
}
この例よりも複雑なプログラムなので、配列にする必要があります。