Hi, I have the following code below. I am getting a memory access violation when accessing cmd->query_string in the loop function. The loop() function is running in another thread. The cmd object appears to be destroyed after calling the send_command function. How do I create an object on the heap and access the query_string. Thanks in advance.
> I am getting a memory access violation when accessing cmd->query_string in the loop function.
The problem is not with accessing the the object; standard library containers (except std::vector<bool> ) are thread safe for simultaneous read access of the same object, and simultaneous modify access of different objects.
Here, you have modify access of the same object from multiple threads; you have to provide a synchronization mechanism from user code.