pass 2D array as argrument

0 maulik trapasiya · September 21, 2015
i want to pass 2D array(this array's size will be given in console) as argument. please tell me how to do it.
   class dArray{

 public : void BinarySearch(int ar[][]){

}
}
   int main(){

       cout << "enter no of row and column you want to insert" << endl;
        int ar_size;
        cin >> ar_size;
    int ar[ar_size][ar_size];
    int ar_i,ar_j;
    for(ar_i = 0; ar_i < ar_size; ar_i++) {
    for(ar_j=0;ar_j<ar_size;ar_j++){
    cin >> ar[ar_i][ar_j];
    }
    }
    dArray d_obj;
    d_obj.BinarySearch(ar);
    }

       
 

Post a Reply

Replies

Oldest  Newest  Rating
0 Jon Z. · September 22, 2015
try specifying the size of the second dimension of the array.
void BinarySearch(int ar[][10])
  • 1

C++

106,942 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator