Difference between Array and classes in c++ programming and what is meaning of anonymous Array ?
Answers
Answer:
A pointer has a value identifying a single point in the machine's logical memory (an address).
An array (in C and C++) is a single (i.e. continguous) block of memory containing 1 or more objects that are homogeneous in type (all exactly the same type).
NB: In Computer Science the term 'array' is used for a wider range of indexed containers. But in C and C++ we tend to be careful to only use them to refer to arrays as defined in the language specifications.
On the one hand they are totally different things. One is an address and the other a block of memory. It's the same as asking "What's the difference between my address and a block of flats". One is set of information that identifies where I live and the other is a building divided into individual dwellings.
However the two concepts get frequently conflated (particularly in C) because when an array is passed to a function in fact what is passed is the address of the first element (as a pointer) and if you have a (correctly typed) pointer (p) to the start of an array you can easily access elements of the array.
This conflation is made worse by the fact that arrays are said to 'decay to pointers'. What is actually happening is the array variable is cast to a pointer to the element type of the array. Nothing happens to the array.
Understanding the difference between a thing and a pointer to that thing is the 'break-through' concept in learning C.
Explanation:
hope it helps