using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Student
{
protected string name;
protected string mof;
protected int year;
protected string dep;
public void Contents_print(string nname, string mmof, int yyear, string ddep)
{
name = nname;
mof = mmof;
year = yyear;
dep = ddep;
Console.Write("이름 : ");
Console.WriteLine(name);
Console.Write("성별 : ");
Console.WriteLine(mof);
Console.Write("나이 : ");
Console.WriteLine(year);
Console.Write("학과 : ");
Console.WriteLine(dep);
Student_print();
}
public virtual void Student_print()
{
Console.WriteLine("학생입니다");
}
}
class Depstudent : Student
{
public override void Student_print()
{
Console.Write(dep);
Console.WriteLine(" 학생입니다");
}
}
class Program
{
static void Main(string[] args)
{
Student han = new Student();
han.Contents_print("홍길동", "남자", 20, "컴퓨터공학과");
Console.WriteLine();
Depstudent goo = new Depstudent();
goo.Student_print();
}
}
}
찐하게 칠한 부분이 Student 의 dep가 출력되게 하고싶은데
왜 안되는지는 알겠는데 어떻게 고쳐야 될지는 모르겠네요,, 기반클래스 멤버필드에 저장된 문자열을 파생클래스에서는 사용할수 없는건가요?
아니면 저장되있는상태가아닌건가?ㅜㅜㅜ 으아아아아아아아아 살려주세요 고수님들!!