+ 3
Difference between default constructor and explicitly defaulted constructor
What is the difference between this class A { protected: A() = default; }; and this class A { protected: A() {} }; This is the code I'm trying to understand. I understand the most parts but why is the default constructor is set to be equal "default" https://github.com/TheCherno/Hazel/blob/master/Hazel/src/Hazel/Core/Input.h
3 Respostas
+ 3
CuRSeD There isn't any difference but if you give your own default constructor then the compiler will not provide the implicit default constructor.
Edit: Just like ~ swim ~ mentioned if you try to use both inside the class then it is not a problem until and unless you are assigning one of them to default.
+ 2
CuRSeD The first case means that you want to use the default constructor provided by the compiler.
Whereas in the second case you have declared a default constructor of your own.
+ 1
@Avinesh Is there any difference between a default constructor provided by the compiler and a default constructor with an empty body? Is it any different between compiler to compiler or it's just syntax sugaring?