In this code getDatabase
function is 3rd party and I can't change it. Inside main
function I have used shared_ptr
. So there is a requirement I have to pass a Database*
to the getDatabase
function by reference. How can I achieve this?
#include <iostream>
#include <memory>
class Database
{
};
void getDatabase(Database*& pDb)
{
pDb = createNewDatabase();
}
int main()
{
std::shared_ptr<Database> pDb=NULL;
getDatabase(pDb.get()); // Here is the issue pDb.get() doesn't do what I need
return 0;
}