Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include "sqlite/sqlite3.h"
  2.  
  3. class foo
  4. {
  5. public:
  6. static sqlite3 *db;
  7. static void connect();
  8. }
  9.  
  10. #include "foo.h"
  11.  
  12. sqlite3 foo::*db = nullptr;
  13.  
  14. foo::connect(){
  15.  
  16. //sqlite3 *db; //<-this works
  17. char *zErrMsg = 0;
  18. int rc;
  19.  
  20. rc = sqlite3_open("test.db", &db);
  21.  
  22. if( rc ){
  23. fprintf(stderr, "Can't open database: %sn", sqlite3_errmsg(db));
  24. exit(0);
  25. }else{
  26. fprintf(stderr, "Opened database successfullyn");
  27. }
  28. //sqlite3_close(db); // close connection when program is exiting. Not here.
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement