pt+1 will print the value of ( address pointed by pt + sizeof(CandyBar) ) which is some location in memory not related to anything in your code.
pt->brand
is how you set that value, so pt->brand
is how you can read that value.
std::cout << pt->brand;
The address of weight, if you really want it, can be found like this:
&(pt->weight)
Last edited on
I understood.thank you guys !