I am writing a c++ class that interfaces with a SQLite database.
Currently I am trying to get back a value from a db. So far I have: (Only showing whats necessary for question)
#include "sqlite3.h"
#include <sstream>
using namespace std;
class ClDBTransporter
{
public:
//Takes in a custom sql statement
//Returns true/false based on if the statement completed sucessfully
bool Custom(string in)
{
//check = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
char *sql = toSql(in);
check = sqlite3_exec(db, sql, callback, NULL, &zErrMsg);
if (check != SQLITE_OK)
{
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
return false;
}
return true;
}
private:
static char *returnedValue;
protected:
static int callback(void *passed, int count, char **data, char **columns)
{
returnedValue = data[0];
return 0;
}
//Used to convert string to char* necessary for sqlite3_exec()
char* toSql(string in)
{
char *y = new char[in.length() + 1];
strcpy(y, in.c_str());
return y;
}
};
Here is a previous callback function I was using:
//callback used to print multiple rows of a SELECT statement
static int callback(void *passed, int count, char **data, char **columns)
{
for (int i = 0; i<count; i++)
{
printf("%s = %s\n", columns[i], data[i] ? data[i] : "NULL");
}
printf("\n");
return 0;
}
I am attempting to access returnedValue throughout the rest of the class for other functions. I will later set up another variable to convert the value of returnedValue to an int, float, or string.
I am unable to compile getting the error:
Error 3 error LNK2001: unresolved external symbol "private: static char * ClDBTransporter::returnedValue" (?returnedValue@ClDBTransporter@@0PADA) H:\CodeLab\SQLite\SQLite\Start.obj SQLite
Error 4 error LNK1120: 1 unresolved externals H:\CodeLab\SQLite\Debug\SQLite.exe 1 1 SQLite
Aucun commentaire:
Enregistrer un commentaire