I decided to create a simple HTML analyzer. By this I mean that it will check that all tags are correctly opened and closed in order e.g. <i><b>hello</i></b> would come back as an error.
So obviously the program will read in from a file into a string object, and then I will search through that string.
Now at first I thought search through and place any tags I found using a stack of strings. Then I realised that might not be the best idea. But what about a vector of strings? I could have an intial element to act as a center point, then add every opening and closing tag either side of the center respectively and if 'n' places away from the center either side do not match, then the tags are not correctly alligned.
I would do it like you originally planned, using a stack to store which tags have been opened, and if you find a closing tag that isn't wanted, you just throw and exception or return an error or whatever.
vector is only good because it assures data will be contiguous which makes for speedy random access. You don't need random access for this because you're only ever interested in the topmost element of the stack. Therefore list is much better suited.
Well, considering the vector class has push and pop member functions...I would argue that a vector could be used just fine, and be much quicker to implement than writing your own stack or list.
Oh, my STL is extremely rusty because I've always been forced to write my own data structures...I had no idea there were lists and stacks in the stl...definitely go with either of those. and thanks for teaching me something new, I'll definitely look into learning more of the STL.