I'm creating a string parser class and there's lots of sub-sub private member functions that all need access to an input. I want to avoid having to put the input as a parameter of every function e.g.
string out = func(input){ sub_func(input) { sub_sub_func(input) } } }
I keep hearing raw pointers are bad, but still not getting a clear answer to this specific situation of "simply using a pointer to refer to something". I could do
string m_str //declared as private member
func(string& input) { m_str = move(input) } //member function
or
string& m_str; //declared as a private member
myclass (string input) : m_str(input); //class construction
but what I want to do is
string m_str* //declared as a private member
func(string input) { m_str = input } //member function
QUESTION
- Do I need to set m_str to nullptr before myclass object goes out of scope (i.e. put this into the class destructor)?
- Should I use unique instead of raw pointer?