Is there any other syntax for this pointer operation?

This is really a basic question, but I'm not sure how to do it.

I have a pointer to a vector (or an array of pointers), say

vector<int *> *p; 

Is there any alternative syntax to index this array other than

 (*p)[i]; 

related operator β†’?

+3
source share
2 answers

p->at(i) similar, but checks the bounds and throws an exception if i out of range. It looks better than yours and Luchian's (IMO) solutions, and a little safer.

+6
source

Yes -

 p->operator[](i); 

but it is not better if you ask me.

+6
source

All Articles