no default constructor exists for class

If you define a class without any constructor, the compiler will synthesize a constructor for you (and that will be a default constructor — i.e., one that doesn’t require any arguments). If, however, you do define a constructor, (even if it does take one or more arguments) the compiler will not synthesize a constructor for you — at that … Read more

C++ error: no matching constructor for initialization of

In the line you are trying to invoke the default constructor of Rectangle. The compiler does not generate such a default constructor anymore, because your Rectangle has a user defined constructor that takes 2 parameters. Therefore, you need to specify the parameters, like The error I get when compiling your code is: Rectangle.cpp:8:15: error: no matching function for … Read more

how to define -std=c++11 as default in g++

Yes, you typically set this in a Makefile: One layer above you can also detect a suitable compiler via autoconf, cmake or whichever other meta-buildtool you might deploy. You of course play games as define g++11 as g++ -std=c++11 but such set-ups are not portable. g++-6.* will default to c++14 so at some this switch will be implicit. But it might take … Read more

Does the Project Lombok @Data annotation create a constructor of any kind?

A @RequiredArgsConstructor will be generated if no constructor has been defined. The Project Lombok @Data page explains: @Data is like having implicit @Getter, @Setter, @ToString, @EqualsAndHashCode and @RequiredArgsConstructor annotations on the class (except that no constructor will be generated if any explicitly written constructor exists).

Inheriting constructors

If your compiler supports C++11 standard, there is a constructor inheritance using using (pun intended). For more see Wikipedia C++11 article. You write: This is all or nothing – you cannot inherit only some constructors, if you write this, you inherit all of them. To inherit only selected ones you need to write the individual constructors manually and … Read more

Inheriting constructors

If your compiler supports C++11 standard, there is a constructor inheritance using using (pun intended). For more see Wikipedia C++11 article. You write: This is all or nothing – you cannot inherit only some constructors, if you write this, you inherit all of them. To inherit only selected ones you need to write the individual constructors manually and … Read more

C++ struct constructor

will try to initialise the array by calling a default constructor for node. You could either provide a default constructor or, rather verbosely, initialise all 100 elements explicitly or, since you’re using C++, use std::vector instead, appending to it (using push_back) at runtime