constructor, is there any ambiguity ?
-
class a{ public: a():rs(&db) {} CRecordset rs;//line a CDatabase db; //line b }; // my question is shld line b comes before line a
-
class a{ public: a():rs(&db) {} CRecordset rs;//line a CDatabase db; //line b }; // my question is shld line b comes before line a
heu, you are trying to create an object, but you assign a member with another member of the same object, which wasn't set yet. so change your code... i'd like to add a remark. your code is note very beautiful, and worse, it is not very useful. put your data members in
private
statement, write your class definition in a .h file, and write the class implementation into a .cpp file :A.h
class CA {
CRecordset rs;
CDatabase db;
public:
CA (void);
//...
}A.cpp
CA::CA(void) : rs(), db() {
}
//...
TOXCCT >>> GEII power
-
heu, you are trying to create an object, but you assign a member with another member of the same object, which wasn't set yet. so change your code... i'd like to add a remark. your code is note very beautiful, and worse, it is not very useful. put your data members in
private
statement, write your class definition in a .h file, and write the class implementation into a .cpp file :A.h
class CA {
CRecordset rs;
CDatabase db;
public:
CA (void);
//...
}A.cpp
CA::CA(void) : rs(), db() {
}
//...
TOXCCT >>> GEII power
i feel that was the most simple way to express his doubt. It'd be funny to have .cpp and .h files along for such a simple question.
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
-
i feel that was the most simple way to express his doubt. It'd be funny to have .cpp and .h files along for such a simple question.
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
-
anyway, his code was wrong ! and you, i'm waiting for your response at your "who's who" page... :-D thx
TOXCCT >>> GEII power
check out, its there!! ;)
It's not a bug, it's an undocumented feature.
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
-
class a{ public: a():rs(&db) {} CRecordset rs;//line a CDatabase db; //line b }; // my question is shld line b comes before line a
Members of class are constructed in order, in which are declared. It doesn't depend on, whether they are initialized in class constructor. And it also doesn't depend on the order of member initializers in class constructor. So in your example the line b should be before the line a. Robert-Antonio "Life is very hard, if you apply E-R model to it."