I'm doing college programming exercises and I'm with this:
Write a program in which a type is defined, PunteroArray, pointer to ARRAY of a thousand positions whose data stored is a pointer to int:
Declare and write a procedure, createArray, to which we pass a variable of PunteroArray and return the necessary dynamic memory to store 1000 integers.
Declare and write the code of a procedure that initializes, initializeArray, a PointerArray variable, which has already been passed to createArray (has the necessary dynamic memory) with values consecutive from 1 to 1000.
Declare and write the code of a procedure, writeArray, that given a variable of PunteroArray, and after calling createArray and initializeArray, enter its values.
Write a main program that calls createArray, initializeArray and writeArray in sequence.
I have this code:
#include <iostream>
#include <cabecera.h>
using namespace std;
int main()
{
PunteroArray array;
return 0;
}
void crearArray(PunteroArray& ar)
{
PunteroArray* ar = new PunteroArray;
}
void inicializarArray(PunteroArray& ar)
{
for(int i=0; i<1000;i++)
{
ar.a[i]=i++;
}
}
When doing build I get the following error:
declaration of 'PointerArray * ar' shadows a parameter PointerArray * ar = new PointerArray;
I understand that means that I am reusing the variable ar, but then, how do I assign dynamic memory to my array in another way?
Thanks in advance.