C++/설명 범범조조 2016. 4. 19. 21:23
-다중 상속#include #include using namespace std; class Man{ string name;public: Man(string name) { this->name = name; } void View() { coutView(); delete bbps; return 0;}
더 읽기
C++/설명 범범조조 2016. 4. 19. 21:22
-상속 일반화 개요//상속 개요#include #include using namespace std; class Musician{ public: void Play() { cout
C++/설명 범범조조 2016. 4. 19. 21:21
-C++에서의 형변환 //static_cast#include #include using namespace std; class Man{ string name;public: Man(string name) { this->name = name; } void View()const { coutStudy(); delete man; return 0;}
C++/설명 범범조조 2016. 4. 19. 21:18
-캡슐화 실습(학생) 시나리오학생은 생성할 때 학생 이름을 전달받습니다.그리고 학생 번호는 순차적으로 부여합니다.이 외에 학생의 국어, 영어, 수학 성적을 -1로 설정 합니다. 학생을 생성한 후에는 학생의 국어, 영어, 수학 성적을 입력할 수 있습니다. 만약 학생 성적이 0에서 100을 벗어나면 -1로 설정합니다. 학생 이름과 번호, 각 과목의 성적과 총점 및 평균을 확인할 수 있습니다. 그리고 전체 학생 수를 확인할 수 있습니다. 그리고 학생 정보를 출력하는 기능을 제공합니다. //Student.h#pragma once#include #include using namespace std; enum SIndex //과목 열거형{ KOREAN, ENGLISH, MATH, MAX_SUBJECT}; class ..
C++/설명 범범조조 2016. 4. 19. 21:16
-캡슐화 실습(학생 성적) //Student.h#pragma once#include #include using namespace std; class Student{ static int last_num; //학생 번호 정적으로 선언 int number; //학생 번호 string name;//학생 이름 int kor; int eng; int math; static const int Def_Kor; //국어점수 디폴트 값 static const int Def_Eng; static const int Def_Math; int sum; double average;public: static int GetStuCount();//정적 메서드 Student(string name); void SetKor(int kor);..
C++/설명 범범조조 2016. 4. 19. 21:14
-캡슐화 실습(복소수)//Complex.h#pragma once#include #include using namespace std; class Complex{ double image; double real;public: Complex(double image = 0, double real = 0); double GetImage(); double GetReal(); void SetImage(double image); void SetReal(double real); const void View();}; //Complex.cpp#include "Complex.h" Complex::Complex(double real , double image ){ SetReal(real); SetImage(image);}doub..
C++/설명 범범조조 2016. 4. 19. 21:12
-복사 생성자//복사 생성자가 필요할 때(개체 내부에 동적으로 생성한 다른 개체를 가질 때)#include using namespace std; class DArray{ int *base; //저장소의 위치 int bcapacity; //저장소의 크기 int usage; //보관 개수public: DArray(int _bcapa) //생성자 { base = new int[_bcapa];//버퍼 동적 할당 bcapacity = _bcapa; usage =0; } DArray(const DArray &src)//복사 생성자(깊은 복사) { base = new int[src.bcapacity]; bcapacity = src.bcapacity; for(usage = 0; usage < src.usage; usa..
C++/설명 범범조조 2016. 4. 19. 21:10
-생성자와 소멸자 //Student.h#pragma once#include #include using namespace std; class Student{ int num; string name;public: Student(void); Student(int num); Student(int num, string name); void View();}; //Student.h#include "Student.h" Student::Student(void){ num = 0; name = "";} Student::Student(int _num){ num = _num; name = "";} Student::Student(int _num, string _name){ num = _num; name = _name;} void ..
C++/설명 범범조조 2016. 4. 19. 21:09
-접근 지정자//Student.h#pragma once#include using namespace std; #define DEF_IQ 100 //디폴트 IQ#define MAX_IQ 300 //최대 IQ class Student{ int num; string name; int iq; public: Student(int _num, string _name); void Study(int hour); void View();}; //Student.cpp#include "Student.h"#include using namespace std; Student::Student(int _num, string _name){ num = _num; name = _name; iq = DEF_IQ;} void Student::St..
C++/설명 범범조조 2016. 4. 19. 21:07
-정적 클래스//정적 클래스#include using namespace std; #define GC GameConst #define GC_MAXHP GC::max_hpclass GameConst{public: static const int max_hp; static const int min_hp; static const int max_iq; static const int min_iq;private: GameConst(); //생성자의 접근 가시성을 private으로 지정}; const int GameConst::max_hp = 200;const int GameConst::min_hp = 0;const int GameConst::max_iq = 300;const int GameConst::min_iq = ..
C++/설명 범범조조 2016. 4. 19. 21:06
-정적멤버 static //Student.h#pragma once#include class Student{ int num; static int last_num; //정적 멤버 필드public: Student(void); int GetNum(); static int GetLastNum(); //정적 멤버 메소드}; //Student.cpp#include "Student.h"int Student::last_num; //static 멤버 필드는 멤버 필드선언을 해야함. 선언문에서는 static 키워드 사용 안 함 Student::Student(void){ last_num++; num = last_num;} int Student::GetNum(){ return num;} int Student::GetLastNu..
C++/설명 범범조조 2016. 4. 19. 21:03
-특별한 멤버 this//this 는 있는 멤버이고 정적인 멤버입니다.//::스코프 연산자#include using namespace std; int num = 1; class Demo{ int num;public: Demo(int num) { this->num = num; } void View(int num)const { cout