dimanche 1 mars 2020

Passing an array class as an argument in c++

I want to pass an array as an argument in a function but I cannot find correct method.I am not talking about normal array (int arr[2]={1,3};). I am talking about array class available from c++ 11. example code:

#include<iostream>
#include<array>
using namespace std;
class test
{
   void function(array<int>myarr)
   {
     .......some code..........
   }
};

How do I pass array like this in function as array class takes two arguments: array<data type,size>name_of_array but while passing it as a argument I do not want to specify the size.

Aucun commentaire:

Enregistrer un commentaire