J
jashugun
Hello to everybody,
I'm trying to write a small program which is meant to interact with an
sqlite database. My idea is to create once a database handler, which
happens to be an opaque pointer (a pointer to a struct which is not
defined anywhere, if I understood correctly). Now, if I had the
possibility of instantiating a concrete struct, I would create a
function like this:
struct sqlite& myDb()
{
static struct sqlite mydb;
return mydb;
}
And then use myDb() whenever the uniquely created object is needed, and
&myDb() whenever the pointer to my database is needed. My moderate
knowledge of C++ does not help me here. I cannot create a concrete
struct sqlite, everything in the API uses an opaque pointer (and
pointers to this pointer). How can I modify the above code and get a
static opaque pointer? I'm actually wondering if it is at all possible.
If not, what do people do in these situations? Is there any widely
accepted/used idiom?
Thank you in advance for any advice,
Alberto
I'm trying to write a small program which is meant to interact with an
sqlite database. My idea is to create once a database handler, which
happens to be an opaque pointer (a pointer to a struct which is not
defined anywhere, if I understood correctly). Now, if I had the
possibility of instantiating a concrete struct, I would create a
function like this:
struct sqlite& myDb()
{
static struct sqlite mydb;
return mydb;
}
And then use myDb() whenever the uniquely created object is needed, and
&myDb() whenever the pointer to my database is needed. My moderate
knowledge of C++ does not help me here. I cannot create a concrete
struct sqlite, everything in the API uses an opaque pointer (and
pointers to this pointer). How can I modify the above code and get a
static opaque pointer? I'm actually wondering if it is at all possible.
If not, what do people do in these situations? Is there any widely
accepted/used idiom?
Thank you in advance for any advice,
Alberto