c++ - Pointers problem -


I have a question that I correctly type in the initial integer indicator int * p and a right By the initial integer array int * array1 = new int []

Which of the following is the legal code?

p = array1;

array1 = p;

Or are both correct?

Is it possible? p [0] Because, in my pointer arithmetic knowledge, it does not add anything.

All in C ++

if pointing to pointers vs pointing arrays They are not always consistent, they are hidden in the submission code because the array immediately changes into an indicator.

  int * array1 = new int [5]; // Legal, hep allocated array starting array with array array array2 [5] = {0}; // declare array directly on array and initalising with zero * int * p = 0; // declare indicator and start numm p = array2; // Legal, Pointer P = array1 specifying array; // specify the pointer for legal, pointer array1 = p; // Specify the pointer to the legal, pointer array2 = p; // ILLEGAL, specifying pointer for array   

Here array2 contains an array type and can not be used to store an indicator. Actually, the array is not assigned at all This can not be done because it is not L-vine.

  int array3 [5] = {0}; // declare the array directly on the stack and the array with the strings array3 = array2; // Unknown, array does not have L-value   

The array has a definite address and it will be like trying to write it again:

  int I = 0; & Amp; I = p;   

[Hopefully, trying to reassign the location of a variable is a clear nonsense.]

Comments