I am a little confused with smart pointers. In the following code, should the & operator return the adress of the smart pointer allocation or the address of the pointer it's controlling?
main() {
std::shared_ptr<int> i = std::shared_ptr<int>(new int(1));
std::shared_ptr<int> j = i;
printf("(%p, %p)\n", &i, &j);
}
Running the code, I got different address. If I run an equivalent code with raw pointers, I get the same adress:
main() {
int e = 1;
int *k = &e;
int *l = k;
printf("(%p, %p)\n",k,l);
}