0

I am using a library which have the following statement in the example -

SqlDatabase db(DB_FILE_NAME, false);

The constructor is defined as

SqlDatabase(const char* szFile, bool useExclusiveWAL = true );

However I want to make this object as a member variable. Which means I want to separate the definition and declaration separately. I can do it like this -

SqlDatabase* db;
db = new SqlDatabase(DB_FILE_NAME, false);

But what if I don't want to make this a non-pointer variable, just like the example? How would I do it?
For example:

SqlDatabase db; //doesn't work in cpp, since there isn't any default constructor, but I can put it in header
db = SqlDatabase(DB_FILE_NAME, false); //Doesn't work

PS: I am sure this is too basic, but I'd still like to know this. I have searched SO, but dunno what this kind of statements are called.

Update:
I've just checked the linked question, but I didn't get any link between what I asked and that member initialization list. I just want the declaration in header and a separate definition in cpp. I don't think this has been answered in the linked question.

0xC0DED00D
  • 19,522
  • 20
  • 117
  • 184

0 Answers0