interface IStudent {
void DoHomework();//做作业
}
class Student1 implements IStudent {
public void DoHomework(){
System.out.println("中学生学习");
}
}
class Student2 implements IStudent {
public void DoHomework(){
System.out.println("大学生学习");
}
}
public class TestStudy {
public static void main(String[]args) {
IStudent s1 = new Student1();
IStudent s2 = new Student2();
s1.DoHomework();
s2.DoHomework();
}
}
我要分 哈哈
public class Student implements IStudent
{
public void DoHomework();
}
大概是这样的,部分关键字记不准了
#include
#include
using namespace std;
class student
{
private:
string sno;
string sname;
public:
student(string sno,string sname)
{
this -> sno = sno;
this -> sname = sname;
}
virtual void DoHomework()
{
cout<<"do himself's homework"<
virtual void printstudent()
{
cout<<"this is a base for class student"<
};
class m_student:public student
{
private:
string schoolname;
public:
m_student(string sno,string sname,string schoolname):student(sno,sname)
{
this -> schoolname = schoolname;
}
void DoHomework()
{
cout<<"do my English homework"<
void printstudent()
{
cout<<"this is a middle school student"<
};
class c_student:public student
{
private:
string schoolname1;
public:
c_student(string sno,string sname,string schoolname1):student(sno,sname)
{
this -> schoolname1 = schoolname1;
}
void DoHomework()
{
cout<<"do my English homework"<
void printstudent()
{
cout<<"this is a college student"<
};
void main()
{
student student1("15","shane");
student1.DoHomework();
student1.printstudent();
m_student student2("15","nicky","xx一中");
student2.DoHomework();
student2.printstudent();
c_student student3("16","bryan","XX大学");
student3.DoHomework();
student3.printstudent();
}