我有两个类,主类和一个连接类:
康涅狄格.cpp:
#include "conn.h"
#include <postgresql/libpq-fe.h>
Conn::getConnection()
{
connStr = "dbname=test user=postgres password=Home hostaddr=127.0.0.1 port=5432";
PGconn* conn;
conn = PQconnectdb(connStr);
if(PQstatus(conn) != CONNECTION_OK)
{
cout << "Connection Failed.";
PQfinish(conn);
}
else
{
cout << "Connection Successful.";
}
return conn;
}
连接器
#ifndef CONN_H
#define CONN_H
#include <postgresql/libpq-fe.h>
class Conn
{
public:
const char *connStr;
Conn();
PGconn getConnection();
void closeConn(PGconn *);
};
主文件
#include <iostream>
#include <postgresql/libpq-fe.h>
#include "conn.h"
using namespace std;
int main()
{
PGconn *connection = NULL;
Conn *connObj;
connection = connObj->getConnection();
return 0;
}
错误:无效使用不完整类型'PGconn {aka struct pg_conn}'
错误:“PGconn {aka struct pg_conn}”的前向声明
有什么帮助吗?