C++ String pointers
- by gnm
In my previous app I had an object like this:
class myType
{
public:
int a;
string b;
}
It had a lot of instances scattered everywhere and passed around to nearly every function.
The app was slow. Profiling said that 95% of time is eaten by the string allocator function.
I know how to work with the object above, but not how to work with string pointers.
class myType
{
public:
int a;
string* b;
}
They told me to use pointers as above.
How much faster is it with a string pointer?
What is copied when I copy the object?
How to the following using the class with the pointer:
Access the string value
Modify the string value without modifying the one in the object (copy?)
General things that change if I use string pointers?