C++ pointers and the identity of pointer in terms of memory allocation -
C++ pointers and the identity of pointer in terms of memory allocation -
as newbie professional concepts of programming, i'm thinking of c++ pointer address of memory block. , logically pointing them indeed pointing first variable.
if int x = 0; if int y points int x; 1 time again if int c points int y, indeed points int x; think true?
my question that, regarding int y , int c, 2 variables pointers, how own memory managed in c++?
in general, question how memory-allocation handled pointers themselves? since pointers prominent way of organizing memory.
thanks in advance
if mean
int x = 0; int* y = &x; int* c = y; then yes, both y , c point x located in memory.
also, both y , c different variables, own memory allocated them. can verified printing address of variables, i.e. printing &y , &c.
more graphically, this:
int x = 0; allocates memory , initializes zero:
+---+ | x | +---+then
int* y = &x; will this:
+---+ +---+ | y | --> | x | +---+ +---+and finally
int* c = y; will create this:
+---+ | y | --\ +---+ \ +---+ >--> | x | +---+ / +---+ | c | --/ +---+also note pointer variables no different other integral variables, value address of point. it's compiler treats them in special way.
c++ c pointers memory memory-management
Comments
Post a Comment