G
G
Gennady Kruglov2019-07-17 14:55:23
OOP
Gennady Kruglov, 2019-07-17 14:55:23

What does this constraint in the class header mean?


class Game< TFamilyType > : IGame where TFamilyType : IFamily, new()
{
//body
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2019-07-17
@robinzonejob

For this restriction to make sense, the Game class must be a generic class with a TFamilyType type parameter.
The constraint says that the type you substitute for TFamilyType when using the Game class must implement the IFamily interface and have a parameterless constructor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question