Search:
Forum
Beginners
Difficulty in understanding
Difficulty in understanding
Jul 22, 2012 at 9:44am UTC
SameerThigale
(95)
int
a[4];
Declares an array of integers of size 4
a
is a pointer to the base element of the array
So my question is, does
a
also occupies a memory as a pointer, different than the memory occupied by the array?
Jul 22, 2012 at 9:48am UTC
Athar
(4466)
a is a pointer to the base element of the array
No, a is an array of int with 4 elements, which you should answer your question.
However, an array can be implicitly converted into a pointer to its first element.
Jul 22, 2012 at 9:58am UTC
SameerThigale
(95)
What does this mean:
an array can be implicitly converted into a pointer to its first element
Jul 22, 2012 at 10:01am UTC
Athar
(4466)
It means that you can do the following:
1
2
3
int
a[4];
int
* b=a;
int
* e=a+4;
Jul 22, 2012 at 10:13am UTC
CMinus
(70)
Sameer Implicit Conversion means that the Compiler converts type to another automatically :) But this has rules :)
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs