본문 바로가기
반응형

01.Bit 단기/C++53

35_다중상속 #include using namespace std; /* 다중상속 : 부모가 2이상... */ class 조류 { public: void 난다() { cout 2018. 5. 3.
34_상속확인 #include using namespace std; /* 상속 부모의 맴버변수+맴버함수를 자식이 상속받는다. 자식은 상속받은 맴버함수 중 일부를 재정의해서 기능을 재구현할 수 있다. 이를 오버라이딩이라 한다. */ class 포유류 { public: void 달린다() { cout 2018. 5. 3.
33_상속,초기화,명시적접근,오버라이드 #include using namespace std; class Musician { protected: const string name; public: Musician(string _name) : name(_name) { } public: void Print() { cout 2018. 5. 3.
32_상속(부모멤버들의 접근지정변경) #include using namespace std; /* 상속(is a) : 일반화관계, 부모와 자식관계 부모의 모든 맴버변수와 맴버함수는 자식에게 상속된다. */ class A { int a; int a1; public: void aa() { cout 2018. 5. 3.
31_상속 #include using namespace std; /* 상속(is a) : 일반화관계, 부모와 자식관계 부모의 모든 맴버변수와 맴버함수는 자식에게 상속된다. */ class A { int a; int a1; public: void aa() { cout 2018. 5. 3.
30_C++ 삽입 삭제 수정 실습 //Member.h #pragma once #include using namespace std; class Member { private: string name; string phone; int age; public: Member(); Member(string _name, string _phone, int _age); ~Member(); public: string getName() const { return name; } string getPhone()const { return phone; } int getAge() const { return age; } void setName(string value) { name = value; } void setPhone(string value) { phone = v.. 2018. 5. 3.
29_C++ 실습 정수의 주소를 n개 저장관리 배열은 차곡차곡 쌓여있다 ------------------------------------------------------------------------------------ class BitArrayList 자료구조 관점에서 3개의 변수 필요 1 저장소 // 값을 저장하는 공간 int arr[10] : 정수 10개 저장 int *arr : 정수 n개 저장 // 동적 메모리 저장 arr = (int*)malloc(sizeof(int)*n); // 힙 메모리에 n개를 저장할 수 있는 공간 생성 // 주소값을 저장하는 공간 int *arr[10]: 정수 주소 10개 저장 int **arr : 정수 주소 n개 저장 // 동적 메모리 저장 arr = (int**)malloc(siz.. 2018. 5. 3.
29_new delete연산자 #include using namespace std; void main() { int *arr1 = new int; //4byte, 쓰레기 int *arr2 = new int(3); //4byte, 초기화 int *arr3 = new int[3]; //12byte, 쓰레기 delete arr1; delete arr2; delete [] arr3; } 2018. 5. 3.
27_has a 최종 문법 코드 #include using namespace std; /* */ class Date { int year, month, day; public: Date(int y, int m, int d) :year(y), month(m), day(d) { } public: int getYear() { return year; } int getMonth() { return month; } int getDay() { return day; } public: void Print() { cout 2018. 5. 3.
반응형