Why can't data class be inherited and how to work around this limitation?
Hello everyone! I'm learning Kotlin and encountered a problem: I want to create a base data class with common fields, and then inherit several data classes from it. For example, there is a base class `Person` with fields `name` and `age`, and from it I want to make `Employee` with an additional field `salary` and `Student` with a field `group`. But the compiler says: "Data class cannot be extended from other classes". Here's my code:
```kotlin
data class Person(val name: String, val age: Int)
data class Employee(name: String, age: Int, val salary: Double) : Person(name, age) // Error!
```
I understand that data class automatically generates `equals()`, `hashCode()`, `toString()`, `copy()` and `componentN()`, and inheritance can break the contracts of these methods. But I need to reuse fields and logic. How to