I have created a class with few public and private functions to create an sqlite database and related operations.consists of 2 private member variables A & B.

Public functions: to check whether database exists ,if exists open and read data A & B else call the 3 functions from private. 2nd function is to generate a 26 char array and store in 25 digit no. Using srand() return it - getA(). 3rd function is to take sha256 **hash concating 2nd function + time-stamp - **getB().

Private functions: to create an sqlite database,to initialize a basic table structure (char A|char B|blob C).3rd function is to generate details to store to database and also to A & B. Both getA() and getB() is called from this function to generate details.

i need help in defining the public functions and also the private function to generate details.
Thanking you.

class Init
{
    char AppID[50];
    char AppCode[50];


    int DbInit() {

        sqlite3 *db;
            if(sqlite3_open("Init.db", &db))
                cout<<"opened database successfully\n";
            else
                cout<< "failed to create database\n";
            return 0;

           }

First observation is that you need to move the sqlite3* db; declaration into the class member variable list, otherwise it will not be accessible outside of the DbInit() method. Also, I would create a set of constructors that call DbInit(), and a virtual destructor that disconnects from the database.

ok.. how can i generate the third private function ie. generate details to store to database and also to A & B. Both getA() and getB() is called from this function to generate details.Code please..

Edited 2 Years Ago by amzz

This article has been dead for over six months. Start a new discussion instead.