Explain C++ pointer initialization -
int value = 3; int *pvalue1 = &value; int *pvalue2(pvalue1); cout << (*pvalue1) << " " << (*pvalue2);
in above code if have noticed have written
int *pvalue2(pvalue1);
instead of
int *pvalue2 = new int; pvalue2 = pvalue1;
still working , giving proper result. can 1 explain me of default function or constructor getting called in case?
int *pvalue2(pvalue1);
is equivalent to
int* pvalue2 = pvalue1;
just assign pvalue2
pvalue1
(assign pvalue2
address of variable value
).
Comments
Post a Comment