I've been following this tutorial, but I get some errors that I don't quite understand. I'm pretty much just have 2 functions, one for closing it, and one for opening it. I'm clueless as to why these errors are here.
DatabaseWriter.h:
#ifndef FILEPARSER_H
#define FILEPARSER_H
#include "DatabaseWriter.h"
using namespace std;
class DatabaseWriter
{
private:
public:
void CloseConn(PGconn *conn);
PGconn DatabaseWriter::*ConnectDB ();
DatabaseWriter ();
};
#endif
DatabaseWriter.cpp
#include "stdafx.h"
#include <string>
#include <string>
#include "libpq-fe.h"
#include "DatabaseWriter.h"
using namespace std;
const char* CONNECTIONSTRING = "user=postgres password=superman dbname=poker hostaddr=127.0.0.1 port=5432";
void DatabaseWriter::CloseConn (PGconn *conn)
{
PQfinish(conn);
getchar();
exit(1);
}
PGconn DatabaseWriter::*ConnectDB ()
{
PGconn *conn = NULL;
// Make a connection to the database
conn = PQconnectdb(CONNECTIONSTRING);
// Check to see that the backend connection was successfully made
if (PQstatus(conn) != CONNECTION_OK)
{
printf("Connection to database failed");
CloseConn(conn);
}
printf("Connection to database - OK\n");
return conn;
}
I defined CloseConn earlier myself, so it shouldn't be undefined.

The return type of ConnectDB is PGconn, conn is a PGconn, so I don't see why it shouldn't return it.

Obviously there are things I'm blatantly looking over, so thanks for your effort.