Determine index from pointers in C++

Well I encountered this problem when I was practicing my DSA, so here I will share how its stored in my mind. In this article, we will look at how to compute the index using pointers returned by STL functions. It will be explained in such a way that even a 4th grader would get it.

Table of contents

IntroductionProblem statementReason for this behaviorHow to solve this issue?
4.1 Solution 1 (Subtracting the starting iterator)
4.2 Solution 2 (Using std::distance())Implementing the solutionsT...
 •  0 comments  •  flag
Share on Twitter
Published on December 11, 2022 07:21
No comments have been added yet.