Copy string &reference to int array[]

I am trying to copy the mem address using &sentenceAlias for the current location.

memoryBlock[counter] is an int and sentenceAlias is a string.

When I use the line below to copy mem location I get error:

memoryBlock[counter] = &sentenceAlias;

error C2440: '=' : cannot convert from 'std::string *' to 'int'

What I dont understand is the address string but cant I copy that to my array to keep track?
C++ does not consider a pointer to be an integer. If you want to store pointers in an array, it will have to be an array of pointers, not an array of integers.

Edit: Apart from anything else, an int may not be be big enough to store a pointer. If you made it an array of long ints, and then explicitly cast the memory address to a long int before storing it, it should work. But why not just store it as a pointer?
Last edited on
Thank you!
Topic archived. No new replies allowed.