It is a bad idea to mix PostgreSQL with C++ for a number of reasons. It is better to wrap your C++ code into C code behind extern C functions. This can be a problem if you heavily use templates and libraries like boost.
For more discussion on use of C++ read the PostgreSQL documentation here http://www.postgresql.org/docs/current/static/xfunc-c.html#EXTEND-CPP.