SqliteModernCpp / sqlite_modern_cpp

The C++14 wrapper around sqlite library
MIT License
904 stars 156 forks source link

how to add database object as a member in class ??? #176

Closed BaderTalal closed 5 years ago

BaderTalal commented 5 years ago

Hi... thanks for the great work, i managed to used the library in my small program but i am facing and issue which might be because my weak understanding of c++ pointers basically i have a class which i added database mDB as a member to it, i could not find the correct way to initialize the database object in my class what i ended doing is like this: in my main() database db1("file name..") myClass mc(db1) // where in the constructor i assigne mDB = db1 i hope if i can pass the file name directly to the constructor and avoid creating external database object out of the class

thanks

BaderTalal commented 5 years ago

sorry... i found it in one of the examples i changed the constroctor to: myclass::myclass(std::string filename): mDB(filename){ // initialization should be in this location not inside the const. body // more work

}