I'm not new to C++, though I am fairly inexperienced, so I always wonder if the new habits showing up are bad or good. Today I realized one that I've had quite a lot lately, and couldn't really decide on my own this time.
So whenever I make a new class, I tend to delete the copy constructor, enforcing whoever is using that class to keep a reference to the original instance or using pointers.
To give an example, here's a simple example with just constructors and destructors
class Foo
{
public:
Foo();
Foo(const Foo &other) = delete;
~Foo();
};
As you can see in the above code example, I have deleted the copy constructor, resulting in the person using Foo
would have to use pointers or references if they want to carry it around.
So to my question, I tend to always do this whenever I make a new struct or class. Always. And should I ever need to have a copy constructor, then I implement one. Is doing stuff like this a bad habit, or is it good practice?