C++프로그래밍

    STL 자료

    보호되어 있는 글입니다.

    [C] 2,3 차원 배열 과 포인터

    회사에서 3차원 배열을 쓰는데 인자로 넘겨서 가져왔는데 안되가지구, 급 테스트 얘는 맨날 헷갈리네 #include int main() { #if 1 int ex[2][2][3] = { {{1,2,3},{4,5,6}}, {{7,8,9},{10,11,12}} }; printf("%d\n", ex[0][0][0]); printf("%d\n", ex[1][0][0]); putchar('\n'); printf("%d\n",(*ex)[0][0]); printf("%d\n",(*ex)[1][0]); printf("%d\n",(*ex)[2][0]); printf("%d\n",(*ex)[3][0]); putchar('\n'); printf("%d\n",(*(ex+1))[0][0]); printf("%d\n",(*(ex+..

    2013.11.25 _ 연산자 오버로딩 연습 _

    연산자 오버로딩 : 연산자 오버로딩은 객체를 대상으로 산술연산, 관계연산, 논리연산을 재정의 하는 것이다. 함수반환형 operator 연산자(연산대상); 연산자 오버로딩 ( = , + ) #include #include using namespace std; class MYSTRING { public: // 디폴트 생성자 MYSTRING() { cpString = 0; uiLen = 0; } // 복사생성자 MYSTRING(MYSTRING &r) { // 디폴트 생성자에서 받은 값을 다시 넣어줌 uiLen = r.uiLen; // 클래스 안에 변수 cpString 에 동적할당 cpString = new char[uiLen+1]; memcpy(cpString, r.cpString , uiLen+1); cout

    2013.11.22 _ 연산자 오버로딩 _

    리턴타입 Class::operator 연산자(인수 목록){ 함수 본체;} 연산자 오버로딩 예제 #include using namespace std; class A { public: int iNum; // 디폴트 생성자 A() { iNum = 0; cout

    2013.11.21 _ 상속에서 멤버 함수 재정의(함수오버로딩,함수오버라이딩)

    함수 오버로딩 : 함수 이름은 같으나 함수의 매개변수는 다르게 정의하는 것 함수오버로딩 예제 // 함수 오버로딩 #include using namespace std; class TwoNumber { public: TwoNumber(); int AddNumber(const int ia, const int ib); double AddNumber(const double da, const double db); private: int i_sum; double d_sum; }; TwoNumber::TwoNumber() { i_sum = 0; d_sum = 0; } int TwoNumber::AddNumber(const int ia, const int ib) { i_sum = ia + ib; return i_sum;..

    2013.11.20 _ 상속 예제 연습

    ● 기반클래스와 파생클래스의 생성자와 호출자 생성자():(const)내부변수초기화 // const(상수) 값을 초기화 시켜줄수 있다.{변수정의} 상속 예제 소스 #include using namespace std; class smart { public: const int A; const int B; smart() :A(100),B(200) // int A = 100 , int A(100) 같은 문법 { cout