Question: I have C++11 app, that uses multiple threads. Each thread can read or write database, eg. doing `INSERT, UPDATE, DELETE, SELECT`.
I have enabled serialized mode for SQLite, so connection can be shared between threads. 

However, I dont know, how to run queries. Can I just run single query and create statement via `sqlite3_prepare_v2`? Or, should I add my own locks via `std::lock_guard<std::mutex>` and do something like:

```
Thread #1
db.lock()
db.query("....").execute()
db.unlock()

Thread #2
db.lock()
res = db.query("....").select()
while(res) res.row()
db.unlock()

```

Or is there any other way? I have been looking for some sample code, but found nothing.

Answer: 
With the: 

```
class MyClass {
private:
    MyClass();
};

```

You are deleting a default constructor. If you want to call a default constructor then (declare or) define or don't define one but don't delete it. Your derived class default constructor will call the base class default constructor:

```
#include <string>
#include <iostream>
#include <memory>

class ICommand {
public:
    std::string name;
    ICommand() : name("The name") { std::cout << "Default base class constructor." << std::endl; }
    virtual void callMe() = 0;
};

class MyCommand : public ICommand {
public:
    MyCommand(){ std::cout << "Default derived class constructor." << std::endl; };
    void callMe() override {
        std::cout << name << std::endl;
    }
};

void f2(const std::string& name) {
    std::shared_ptr<ICommand> p = std::make_shared<MyCommand>();
    p->callMe();
}
int main(){
    f2("asdasd");
}

```

**Part 2:**  

If you are trying to use the above classes in a polymorphic way then make your `ICommand` member functions pure virtual:

```
virtual void callMe() = 0; 
virtual void callMe2() = 0;

```

Modify the `void f` function to:

```
void f(const std::string& name) {
    std::shared_ptr<ICommand> p = std::make_shared<MyCommand>(name);
    p->callMe();
}

```

[Live example](http://coliru.stacked-crooked.com/a/4580df72f6d60bf0) on Coliru.
```
class ICommand {
private:
  ICommand() = default;
public:
  const std::string name;
  ICommand(const std::string& name) : name(name) { }
  virtual ~ICommand() = default;
  virtual void callMe() = 0; 
  virtual void callMe2() = 0;
};

```