exception: Access violation-Collection of common programming errors

What’s wrong with this code below and how to fix it.

#include
using namespace std;

template
class guard{
public:
    guard(Func1 first, Func2 last) : last(last){
        first();
    }
    ~guard(){
        last();
    }
private:
    Func2& last;
};

template
guard make_guard(Func1 first, Func2 last){
    return guard(first, last);
}

void first(){
    cout

Originally posted 2013-11-09 20:52:15.