게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
c# 코드 질문이요,,, 부탁두려요 ㅠㅠ
게시물ID : computer_135726짧은주소 복사하기
작성자 : 슷구
추천 : 0
조회수 : 288회
댓글수 : 3개
등록시간 : 2013/12/16 07:19:51
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가 출력되게 하고싶은데
왜 안되는지는 알겠는데 어떻게 고쳐야 될지는 모르겠네요,, 기반클래스 멤버필드에 저장된 문자열을 파생클래스에서는 사용할수 없는건가요?
아니면 저장되있는상태가아닌건가?ㅜㅜㅜ 으아아아아아아아아 살려주세요 고수님들!!
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호