实例化一个抽象类 [英] instantiating an abstract class

查看:87
本文介绍了实例化一个抽象类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要访问抽象类中的一些数据。虽然你不能对抽象类产生反感。


要做的任务是从文本文件中收集数据,其中数据采用这种格式。

P Charles Galea 134


如果我的班级需要检查第一个字母是否是P,它会在教授课程中完成这些内容,如果它是S,那么它会在Students课程中完成。教授和学生班继承了下面的SchoolMember抽象类。

I need to access some data which is in an abstract class. Though you cannot inistialise an abstract class.

The task to do is gathering data from a textfile where data is in this format..
P Charles Galea 134

Where my class needs to check if the first letter is a P it do the stuff in the professors class and if it is an S it do the stuff in the Students class. The professor and student class inherits the SchoolMember abstract class which is follows.


展开 | 选择 | Wrap | 行号

推荐答案

你的主题标题没有任何意义。您无法实例化抽象类。讨论的问题与抽象类无关。如果您想知道如何阅读文件,可以阅读这篇文章
Your thread title does not make any sense. You cannot instantiate an abstract class. The problem discussed has nothing to do with abstract classes. If you want to know how to read files you can read this article



我需要访问抽象类中的一些数据。虽然你不能对抽象类产生反感。


要做的任务是从文本文件中收集数据,其中数据采用这种格式。

P Charles Galea 134


如果我的班级需要检查第一个字母是否是P,它会在教授课程中完成这些内容,如果它是S,那么它会在Students课程中完成。教授和学生班继承了SchoolMember抽象类,如下所示。
I need to access some data which is in an abstract class. Though you cannot inistialise an abstract class.

The task to do is gathering data from a textfile where data is in this format..
P Charles Galea 134

Where my class needs to check if the first letter is a P it do the stuff in the professors class and if it is an S it do the stuff in the Students class. The professor and student class inherits the SchoolMember abstract class which is follows.

展开 | 选择 < span class =codeDivider> | Wrap | 行号


我会说:抽象基类中的静态工厂方法。


亲切的问候,


Jos
I''d say: a static factory method in the abstract base class.

kind regards,

Jos


这篇关于实例化一个抽象类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆