math4tots
math4tots

Reputation: 8870

Controlling instantiation and member variables in C++

From what I understand, when you create a C++ class, you implicitly have a default no argument constructor, a default copy constructor, and a default assignment operator.

If I want to be sure that I am alerted every time an instance of my object is created, or my object is mutated (e.g. through assignment), are these the only methods/constructors I have to worry about, given I keep all of my fields private?

Upvotes: 2

Views: 97

Answers (2)

japreiss
japreiss

Reputation: 11251

If the data members of your class are modified by an attack or a pointer manipulation error, you won't get alerted. Not sure if that was part of the question or not.

Upvotes: 0

WendiKidd
WendiKidd

Reputation: 4373

If everything else in your class is private, yes.

Though do keep in mind that, if other people might have their hands in this code, unexpected modification might end up occurring in the private methods as well. So you might want to keep an eye on them too.

Upvotes: 2

Related Questions