jezz
10th April 2011, 16:24
The Assistant said:
"QSqlDatabase is a value class. Changes made to a database connection via one instance of QSqlDatabase will affect other instances of QSqlDatabase that represent the same connection."
What does it mean by "value class"?
I only have one database connection in my application. Should I use a pointer to it everywhere in the program? Or shouldn't I?
class MyApp1:public QApplication {
public:
QSqlDatabase db() {
return db;
}
private:
QSqlDatabase db;
}
class MyApp2:public QApplication {
public:
QSqlDatabase *db() {
return &db;
}
private:
QSqlDatabase db;
}
Which is better? MyApp1 or MyApp2 ?
Thanks !
"QSqlDatabase is a value class. Changes made to a database connection via one instance of QSqlDatabase will affect other instances of QSqlDatabase that represent the same connection."
What does it mean by "value class"?
I only have one database connection in my application. Should I use a pointer to it everywhere in the program? Or shouldn't I?
class MyApp1:public QApplication {
public:
QSqlDatabase db() {
return db;
}
private:
QSqlDatabase db;
}
class MyApp2:public QApplication {
public:
QSqlDatabase *db() {
return &db;
}
private:
QSqlDatabase db;
}
Which is better? MyApp1 or MyApp2 ?
Thanks !