A C++ class has 4 essential functions: Constructor, destructor, copy constructor and assignment operator. You are supposed to define them explicitly, but if you don't, the compiler will generate them for you. But as Scott Meyer says, compiler will only generate them if it needs to. There are many conditions, but for example, if a class is bit-wise copyable, compiler will not generate a copy constructor.
So if I have an empty class as this:
class A {};
I would assume, compiler is not going to generate any functions for this. I have couple of questions:
How do I see the compiler generated functions? For example, I am able to see my functions in the class symbol table calling nm on the object file. In the symbol table, although the names are mangled, I can clearly identify the functions I declared. But I cannot see any constructors, etc. How do I see the functions that are generated by the compiler?
What does it mean to create an instance of an empty class? I know C++ puts a memory allocation of 1 to empty classes to make each instance have a unique address. But if there is no default compiler generated constructor, what does it mean to do:
A a1 = A(); A *a1ptr = new A();
Or should it be
A a2 = A;
Cheers