用sqlite数据库创建一个类.. [英] creating a class with sqlite database..
问题描述
我正在使用Qt creator ide和纯c ++编码。我需要创建一个包含2个成员变量A和B(也在表中添加)和3个公共和私有函数的类。
公共函数:检查数据库是否存在,是否存在打开和读取数据A&B从private调用3个函数。函数是生成一个26字符数组并存储在25位数字中。使用srand()返回它 - getA()。第三个函数是取sha256 hash concating第二个函数+ timestamp - getB()。
私有函数:创建一个sqlite数据库,初始化一个基本表结构(char A | char B | blob C).3rd functon用于生成存储到数据库以及A&B的细节。从此函数调用getA()和getB()以生成详细信息。
如何定义问题中提到的公共函数(使用srand()&sha256库)?
Jochen Arendt对谷歌这些功能是正确的。它们是标准功能,所以花时间学习它是很好的投资。
我的提示是,为每个操作编写一个具有良好名称的自己的函数。像CheckDatabaseExist等。并返回一个值并检查下一步。
祝你好作业:-)
(问题显示代码和输出)
I am using Qt creator ide with pure c++ coding. I need to create a class with 2 member variables A & B (also added in the table)and 3 public and private functions.
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 + timestamp - getB().
Private functions: to create an sqlite database,to initialise a basic table structure (char A|char B|blob C).3rd functon is to generate details to store to databse and also to A & B. both getA() and getB() is called from this function to generate details.
How can i define the public functions mentioned in the question ( using srand() & sha256 library) ?
Jochen Arendt is right to google for these functions. They are standard function, so spending time to learn it is well invested.
My tip is, to write for every operation a own function with a good name. Like "CheckDatabaseExist" and so on. And return a value and check it for the next step.
good luck for your homework :-)
(for questions show code and output)
这篇关于用sqlite数据库创建一个类..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!