Question: Trying to add a portfolio gallery to a custom wp theme I am making. I have exhausted myself on trying to search for solutions and plugins that could even be modified some. I think one of my issues in finding a solution is that I am not entirely sure what search terms would help me find something similar to what I am trying to achieve..

As of right now, I have the following div for my navigation

```
<div id="tags" role="navigation">
<p>
<a class="portrait" href="#portrait">Portrait</a> / 
<a class="landscape" href="#landscape">Landscape</a> / 
<a class="sports" href="#sports">Sports</a> / 
<a class="nature" href="#nature">Nature</a> / 
<a class="weddings" href="#weddings">Weddings</a> / 
<a class="active" href="#">All</a>
</p>
</div>

```

Below my navigation is where I have my images div. What I would like to do is be able to select a category from the images navigation and have only those specifically tagged images show. What I don't want is to have a new page open up for that tag/selection made. I would like to have the images reorganize or fade in/out for the selected navigation.

Im sure there is a script or plugin out there that would be similar to what I am looking for. Or a little guidance/suggestion on how to best achieve this would be appreciated.

Thanks in advance.

Answer: 
For C++, the answer is in the C++ FAQ.

[How can I handle a constructor that fails?](http://www.parashift.com/c++-faq/ctors-can-throw.html)

[How should I handle resources if my constructors may throw exceptions?](http://www.parashift.com/c++-faq/selfcleaning-members.html)

More info from [GOTW](http://www.gotw.ca/gotw/066.htm)
Whether you get a memory leak or not depends on how the code is written. If you write "good" code, you shouldn't have a memory leak. But it's entirely possible to come up with scenarios where this goes horribly wrong. 

If the constructor allocates anything in the constructor, then things may well go wrong. 

The solution, in general is to use what's called "two-phase construction", so the constructor itself is very simple and "can't go wrong". Once the object is constructed, you call a member function that fills in the object in ways that could perhaps fail, and you can then throw exceptions at will, and as long as it's ensured that the destructor is run at some point down the line, all should work out well. Beware of "part-constructed object in destructor" tho' - what happens if your pointers are NULL, or if something else hasn't been constructed partway through the destructor. 

[The above is subject to "there is a handler somewhere before we get back to main, and we do actually want to do something other than abort the entire program"].