c++ - How to pass an array by reference? -


I'm trying to overcome this array from context but my code is not capable of taking the function. help?

  #include & lt; Iostream & gt; using namespace std; Zero print (int (and array) [], int lower-bound, int ex-bound); Int main () {// generated array int int = 20; int array [size]; For (int i = 0; i    

How to pass an array by reference in CPP?

You got almost the correct syntax, but you need the size of the array, which you can clearly specify if you only have to support one size:

  const int SIZE = 20; Zero print (int (and array) [SIZE], int lower-over, array upper-bound);   

To use this function template to remove it, if you need a function for different sizes:

  template & lt; Size_t N & gt; Zero printed (Ant and Arrayage) [n], int lower-bend, int extbound) {// code here}   

Note that there are more idiotic solutions in C ++ To specify and specify the one-past-the-end-enders (plain pointers), others have std :: arrays for arrays of fixed size and std for people with dynamic size :: vector to use.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -