title: Is that possible to define mongo::DBClientReplicaSet as a global variable in a class?
body: <p>I am using c++ legacy driver, I built a class with many mongoDB operations in different functions.</p>
  
  <p>I don't want to define the <code>mongo::DBClientReplicaSet</code> in every function but if I define it in the global level, I had another problem because I need to call <code>mongo::client::initialize</code> before I construct any driver objects, or BSON for that matter. That means if I call <code>mongo::client::initialize</code> in the class construct function, I cannot define <code>mongo::DBClientReplicaSet</code> before that. So it cannot be declared in the global level. I tried "<code>extern mongo::DBClientReplicaSet xxxx</code>" and then defined it in class construct function but got link error : </p>
  
  <blockquote>
    <p>error LNK2001: unresolved external symbol "class
    mongo::DBClientReplicaSet xxxx"</p>
  </blockquote>
  
  <p>because we cannot use <code>mongo::DBClientReplicaSet</code> without parameters.</p>
  
  <p>Does anybody know a solution for this?</p>