What is the best way to give a C# auto-property an initial value?

In C# 5 and earlier, to give auto implemented properties an initial value, you have to do it in a constructor. Since C# 6.0, you can specify initial value in-line. The syntax is: DefaultValueAttribute is intended to be used by the VS designer (or any other consumer) to specify a default value, not an initial value. … Read more

Java class “cannot be resolved to a type”

The problem is that TeamLeader appears to be an inner class (hard to tell, your indentation is bad), and since it’s not static, you can’t instantiate it by itself. You either need to make TeamLeader its own class, or make it a static class and instantiate it as Employee.TeamLeader (or whatever the parent class is, your indentation is really not helpful here).

c++: No instance of overloaded function?

You’ve not included <string> header file in stock.h header file, even though you’re using std::string in it. Maybe that is causing this error message (if that is the case, then I would say its really a bad message). Another problem is that in Stock class definition, you’ve written this: which is wrong. Remove Stock:: from it, and make it like this: Stock:: is required when defining … Read more

Why do C++ objects have a default destructor?

It’s wrong to say that a compiler-generated default constructor takes no action. It is equivalent to a user-defined constructor with an empty body and an empty initializer list, but that doesn’t mean it takes no action. Here is what it does: It calls the base class’es default constructor. It initializes the vtable pointer, if the … Read more