I want to ask where is an std::string stored? I am little confused about it. What I understand is that it is stored in the stack and it has a pointer to dynamically allocate space in the heap. Is this correct?
Is there any point to declare a string as new inside a class to avoid the class scope (if the class object gets destroyed) and continue on using my std::string?
the other objects need to use their own copy of the string, rather than using a pointer,
create the string outside the objects, so you have control over when it is created and destroyed.
The best solution really depends on what exactly you're trying to accomplish.
Do the objects that use the string never change the string? Do those objects need to change which string they refer to?
One possible solution is to use a variation of the map scheme you were already ready using. You could store the (const) strings in the map as a key with a reference counter as the data and have your objects reference those strings (via pointer or reference depending on the requirements of your objects), increasing or decreasing the reference count as the objects attach or detach themselves from the string. Of course, you cannot change the strings stored this way, as it would screw up the ordering of the map. If you need to 'change' a string you'd need to make a copy, make the changes, and insert the 'changed' string into the map.
If, on the other hand, changes made to a string should be propagated to other objects that refer to the same string, a vector or deque may be a more appropriate container.
Another possibility is just to use a copy-on-write string implementation, or a smart pointer that manages the lifetime of the object.
But, you don't really give enough information about what you're trying to accomplish to really make a recommendation.