Hello!
I have a question about constant pointers. I am aware that with regular pointers, you can access the memory addresses next to a certain memory address to handle arrays/vectors, etc. such as in this example:
However, I have a function to which I am passing such a base object. I want the base object to be constant so that I can always keep track of where the start of the array is. It appears though that accessing memory offset from a constant pointer cannot be done in the same way, as in this example:PHP Code:#include <iostream>
void main() {
vector<SomeClass_t> objects (10);
SomeClass_t* baseobject (&objects[0]);
std::cout << (baseobject + 2)->somefunc(); //would reference objects[2]
}
This would return the error " Cannot convert from 'const SomeClass_t' to 'SomeClass_t&' "PHP Code:#include <iostream>
void main() {
vector<SomeClass_t> objects (10);
const SomeClass_t* BASEOBJECT (&objects[0]);
std::cout << (BASEOBJECT + 2)->somefunc(); //error
}
Is there a special way of handling this, or should I be looking for a different way to handle this scenario?
Thanks in advance!

