This is similar to the definition of the term “object,” so the statement is a tautology. In particular, with respect to Java, it seems to define an “object” to denote an instance of a class. As for C ++, it (apparently) uses a wider definition of an object, which includes things like primitive types that don't even have constructors.
Regardless of its definitions, however, C ++ and Java are much more alike than different in this respect. Both have primitive types that don't even have constructors. Both support the creation of custom types, which guarantee the invocation of constructors when creating objects.
C ++ also supports the creation (within very defined limits) of user-defined types that do not necessarily have constructors called under all possible circumstances. However, there are strict restrictions on this. One of them is that the constructor must be "trivial", i.e. It should be a constructor that does nothing that was automatically synthesized by the compiler.
In other words, if you write a class with a constructor, then the compiler can use it at the right time (for example, if you write a copy constructor, all copies will be made using your copy constructor). If you write a default constructor, the compiler will use it to create all objects of this type for which an initializer is not specified, etc.
Jerry Coffin
source share