Is that possible to define mongo::DBClientReplicaSet as a global variable in a class?

88 views Asked by At

I am using c++ legacy driver, I built a class with many mongoDB operations in different functions.

I don't want to define the mongo::DBClientReplicaSet in every function but if I define it in the global level, I had another problem because I need to call mongo::client::initialize before I construct any driver objects, or BSON for that matter. That means if I call mongo::client::initialize in the class construct function, I cannot define mongo::DBClientReplicaSet before that. So it cannot be declared in the global level. I tried "extern mongo::DBClientReplicaSet xxxx" and then defined it in class construct function but got link error :

error LNK2001: unresolved external symbol "class mongo::DBClientReplicaSet xxxx"

because we cannot use mongo::DBClientReplicaSet without parameters.

Does anybody know a solution for this?

0

There are 0 answers