Student.h
#include <iostream>
#include <string>
using namespace std;

class Student
{
	protected:
		string name;		//이름
		string id;			//학번
		string major;		//전공
		unsigned int grade;	//학년
		unsigned int credit;//학점

	public:
		Student();
		~Student();	
};

Student::Student()
{
	/* Do nothing */
}

Student::~Student()
{
	/* Do nothing */
}
graduate.h
class Graduate:private Student
{
	private:
		string assistant;	//조교
		float scholarship;	// 장학금

	public:
		Graduate(string s_name, string s_id, string s_major, unsigned int i_grade, unsigned int i_credit, string s_assistant, float f_scholarship);
		~Graduate();
		void print(void);
};


Graduate::Graduate(string s_name, string s_id, string s_major, unsigned int i_grade, unsigned int i_credit, string s_assistant, float f_scholarship)
{
	name = s_name;
	id = s_id;
	major = s_major;
	grade = i_grade;
	credit = i_credit;
	assistant = s_assistant;
	scholarship = f_scholarship;
}

Graduate::~Graduate()
{
	/* Do nothing */
}

void Graduate::print(void)
{
	cout << "이름" << " : " << name << "\n";
	cout << "학번" << " : " << id << "\n";
	cout << "전공" << " : " << major << "\n";
	cout << "학년" << " : " << grade << "\n";
	cout << "이수학점" << " : " << credit << "\n";
	cout << "조교유형" << " : " << assistant << "\n";
	cout << "장학금비율" << " : " << scholarship << "\n";
}

UnderGraduate.h
class UnderGraduate:private Student
{
	private:
		string circle;	//동아리

	public:
		UnderGraduate(string s_name, string s_id, string s_major, unsigned int i_grade, unsigned int i_credit, string s_circle);
		~UnderGraduate();
		void print(void);
};


UnderGraduate::UnderGraduate(string s_name, string s_id, string s_major, unsigned int i_grade, unsigned int i_credit, string s_circle)
{
	name = s_name;
	id = s_id;
	major = s_major;
	grade = i_grade;
	credit = i_credit;
	circle = s_circle;
}

UnderGraduate::~UnderGraduate()
{
	/* Do nothing */
}

void UnderGraduate::print(void)
{
	cout << "이름" << " : " << name << "\n";
	cout << "학번" << " : " << id << "\n";
	cout << "전공" << " : " << major << "\n";
	cout << "학년" << " : " << grade << "\n";
	cout << "이수학점" << " : " << credit << "\n";
	cout << "동아리" << " : " << circle << "\n";
}

Main.cpp
#include "student.h"
#include "under_graduate.h"
#include "graduate.h"

int main()
{
	Graduate g("홍길동","20051111","컴퓨터공학과",4, 140,"연구조교", 0.5);

	UnderGraduate u("하길동","20011111","컴퓨터공학과",2, 80,"Visaul C++");

	g.print();
	cout<<"-------------------------"<<endl;
	u.print();

	return 0;
}

PS. VS2010 문제인지, 오랬만에 해서 뭔가 헛갈리는 건지 모르겠지만... Include 중복 문제가 있어서 이 코드는 좀 우습게 되었습니다. 참고만 하세요.
Posted by 지그프리드 지그프리드

댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절


BLOG main image
일상, 프로그래밍, IT 그리고 직장생활, Dive, 여행 by 지그프리드

카테고리

Class List (402)
Studies (30)
Exercise & Quizz (10)
Term Project (0)
ECIM list (Help!) (10)
Issues & News (0)
Gossip about IT & Job (22)
Tools (2)
Think about the Justice (23)
Book Review (170)
조엘 온 소프트웨어(번역) (28)
Diary (87)
Vacations (9)
Clash of clans 클래시 오브.. (11)

글 보관함

달력

«   2019/11   »
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Total : 315,137
Today : 26 Yesterday : 27