How do you name your iterators when you return a begin and an end iterator from a class? Without it sounding clunky, that is.


typedef std::vector<Idea> Ideas_Type;

Ideas_Type::const_iterator GetIdeasBegin() const;
Ideas_Type::const_iterator GetIdeasEnd() const;

Should it be GetIdeasBeginIter? IdeasBegin?

  • This question appears to be off-topic because it is a "name that thing" question. "Name that thing" are bad questions for the same reasons that "identify this obscure TV show, film or book by its characters or story" are bad questions: you can't Google them, they aren't practical in any way, they don't help anyone else, and allowing them opens the door for the asking of other types of marginal questions. See blog.stackoverflow.com/2012/02/lets-play-the-guessing-game
    – gnat
    Commented Mar 20, 2014 at 8:40

2 Answers 2


It's unclear from your question, but if you are thinking of something like this:

class Brain {
  typedef std::vector<Idea> Ideas; // Not "Ideas_Type".  That's why it's capitalized.
  Ideas::const_iterator firstIdea();
  Ideas::const_iterator lastIdea();

There's no need for all that. You may as well say

class Brain {
  const Ideas &ideas();

By returning a constant reference to the collection, it allows callers to process the collection as they see fit without modifying it. If you don't want to expose the entire vector interface, then you can create a small class like this:

class my_list<T>: private std::vector<T> {
  // whatever methods you like, including begin(), end(), ...

And as a matter of style, save "get" methods for legacy languages.


I would mimic the naming done in the STL. Now your classes work with many built-in functions.

  • begin
  • end

  • rbegin
  • rend
  • There are some libraries that will take advantage of appropriately named interfaces (begin, end for example) to allow operations on a container directly.
    – Bill Door
    Commented Jul 17, 2012 at 20:47
  • 4
    Also cbegin and cend in the new standard.
    – Klaim
    Commented Jul 17, 2012 at 21:32
  • @BillDoor : cprogramming.com/c++11/c++11-ranged-for-loop.html this requires methods called begin and end be present in your class.
    – gbjbaanb
    Commented Jul 18, 2012 at 14:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.