标题:跪求高手...请问下面一代码那里错误了....
取消只看楼主
不要害怕俊杰
Rank: 1
等 级:新手上路
帖 子:15
专家分:1
注 册:2012-9-9
结帖率:100%
已结贴  问题点数:20 回复次数:3 
跪求高手...请问下面一代码那里错误了....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _2._12
{
    class Program
    {
        public class Student
        {
            private string m_name;
            private int m_grade;
            public string Name
            {
                get
                {
                    return m_name;
                }
                set
                {
                    this.m_name = value;
                }
            }
            public int Grade
            {
                get
                {
                    return m_grade;
                }
                set
                {
                    m_grade = value;
                }
            }
            public Student()
            {
                Grade = 1;
            }
            public abstract string Introduce();
       }
        public class Pupil : Student
        {
            public override string Introduce()
            {
                if (Grade >= 1 && Grade < 7)
                    return "This is an pupil of grade " + Grade;
                else
                    return "No such grade";
            }
        }
        public class Undergraduate : Student
        {
            public override string Introduce()
            {
                if (Grade > 0 && Grade < 5)
                    return "This is an undergraduate of grade" + Grade.ToString();
                else
                    return "No such grade";
            }
        }
        public class Graduate : Student
        {
            public override string Introduce()
            {
                if (Grade >= 1 && Grade < 4)
                    return "This is a graduate of grade " + Grade;
                else
                    return "No such grade";
            }
        }
        static void Main(string[] args)
        {
            Student student;
            Pupil pu = new Pupil();
            student = pu;
            pu.Grade = 5;
            Console.WriteLine(student.Introduce());
            Undergraduate un = new Undergraduate();
            student = un;
            un.Grade = 5;
            Console.WriteLine(student.Introduce());
            Graduate gr = new Graduate();
            student = gr;
            Console.WriteLine(student.Introduce());
            Console.WriteLine("按回车键结束");
            Console.Read();
        }
    }
}
报这个错误....Introduce()是抽象类但他包含了非抽象类....
跪求高手改正错误...
搜索更多相关主题的帖子: return public private 
2012-09-15 10:33
不要害怕俊杰
Rank: 1
等 级:新手上路
帖 子:15
专家分:1
注 册:2012-9-9
得分:0 
回复 2楼 lybh24
谢谢...
2012-09-15 20:17
不要害怕俊杰
Rank: 1
等 级:新手上路
帖 子:15
专家分:1
注 册:2012-9-9
得分:0 
回复 3楼 ZWYyj
谢谢啦...
2012-09-15 20:17
不要害怕俊杰
Rank: 1
等 级:新手上路
帖 子:15
专家分:1
注 册:2012-9-9
得分:0 
回复 6楼 跳过去
这个只是考试的题目啊...
2012-09-20 17:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-381447-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.054881 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved