I know it applies differently in different situations, but I want to ask about the general recommended style.
I am currently getting a pointer from outside and store it inside of the class like this.
class Foo
{
private:
T* m_P;
public:
Foo(T* p) : m_P(p)
{
}
~Foo()
{
delete m_P;
}
};
int main()
{
T* a = someValue;
Foo foo(a);
}
What I want is m_P and a pointing the same value.
This code works as I want, but using raw pointers feels unsecured.
What is the secured code of this program?