开发者

VB.Net: Class Inheritance make one class another

开发者 https://www.devze.com 2022-12-28 14:25 出处:网络
I have an organization that has clients and students, every student begins as a client. If I have a Client clas开发者_运维百科s and a student class that inherits from client. How do I make a client a

I have an organization that has clients and students, every student begins as a client. If I have a Client clas开发者_运维百科s and a student class that inherits from client. How do I make a client a student?


Public Class Client
   ' code here...
End Class

Public Class Student
    Inherits Client
    ' code here...
End Class


It sounds like your problem involves persistence more than inheritance. If you have a client, presumably the persistent data is stored in a client table. When this client becomes a student, you could create a record in a student table containing the student information and the id of the client record. A client object would be loaded from the client table, while a student object would pull data from both client and student tables. Relating the data means client info would never be duplicated, while making it simple to retrieve either client info, or student--including client--info.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号