Microsoft PowerPoint - 8ÀÏ°_Æ÷ÀÎÅÍ.ppt

Size: px
Start display at page:

Download "Microsoft PowerPoint - 8ÀÏ°_Æ÷ÀÎÅÍ.ppt"

Transcription

1 포인터 1

2 포인터란? 포인터 메모리의주소를가지고있는변수 메모리주소 100번지 101번지 102번지 103번지 int theage (4 byte) 변수의크기에따라 주로 byte 단위 주소연산자 : & 변수의주소를반환 메모리 2

3 #include <iostream> list 8.1 int main() using namespace std; unsigned short shortvar=5; unsigned long longvar=65535; long svar = ; cout << "shortvar:\t" << shortvar; cout << "\taddress of shortvar:\t"; cout << &shortvar << "\n"; cout << "longvar:\t" << longvar; cout << "\taddress of longvar:\t" ; cout << &longvar << "\n"; cout << "svar:\t\t" << svar; cout << "\taddress of svar:\t" ; cout << &svar << "\n"; return 0; shortvar : 5 Address of shortvar: 0012FF7C longvar : Address of longvar: 0012FF78 svar: Address of svar: 0012FF74 3

4 포인터선언 포인터선언방법 int *page = 0; 정수형변수의주소를담는 ( 가리키는 ) 변수 ( 포인터 ) page 는변수 저장되는내용은주소로해석 Null 과 Wild 포인터 null 포인터 : 0 으로초기화된포인터 wild 포인터 : 초기화되지않은포인터 포인터값할당 int howold = 50 ; int *page = 0 ; page = &howold; int howold = 50 ; int *page = &howold; 4

5 간접지정 (indirection) 연산자 간접지정연산자 메모리주소 포인터를사용하여실제값접근 (page를사용하여 howold 값에접근 ) int howold = 50 ; int *page = &howold; 100번지 101번지 102번지 int howold (4 byte) 100 page cout << page ; cout << *page ; 주소값이가리키는실제값을찾아가게함 5

6 구별 포인터변수 포인터, 주소, 변수 포인터변수에저장된주소값 포인터변수에저장된주소값이가리키는메모리에저장된실제값 100번지 int thisval 101번지 102번지 104 번지 int thatval 108 번지 int *pptr int thisval = 5; int thatval = 7; int *pptr = &thisval; int dbl_this = 2 * *pptr; pptr = &thatval; int dbl_that = 2 * *pptr; 6

7 #include <iostream> list 8.2 typedef unsigned short int USHORT; int main() using std::cout; USHORT myage; // a variable USHORT * page = 0; // a pointer myage = 5; cout << "myage: " << myage << "\n"; page = &myage; cout << "*page: " << *page << "\n\n"; cout << "Setting *page = 7...\n"; *page = 7; cout << "*page: " << *page << "\n"; cout << "myage: " << myage << "\n\n"; cout << "Setting myage = 9...\n"; myage = 9; cout << "myage: " << myage << "\n"; cout << "*page: " << *page << "\n"; return 0; 7

8 포인터를사용하는이유 자유기억장소의자료를다룰때 클래스멤버자료와클래스멤버함수에접근할때 함수에주소전달을할때 8

9 자유기억공간 (heap) 메모리의 5 가지영역 코드영역 전역공간 : 전역변수관리 스택 : 지역변수, 함수의매개변수관리 자유기억공간 레지스터 : special / general purpose register 지역변수의문제점 지속성 동적으로변수를잡을수없음 int num; std:: cin >> num ; int array[num]; 자유기억공간의이점 공간을제거하기전까지는메모리유지 동적으로변수를잡을수있음포인터로자유기억공간에대한접근및관리포인터를가진함수만이자유기억공간에접근가능 9

10 자유기억공간할당및해제 할당 ( new ) new 객체의형 ( 초기화값 ) new 객체의형 [ 개수 ] 자유기억장소할당및메모리주소반환 new unsigned short int new long (10000) new int [10] 2byte 자유기억장소할당 4byte 자유기억장소할당 (10000 으로초기화 ) 4byte 자유기억장소 10 개할당 10

11 자유기억공간할당및해제 (cont.) 자유기억공간사용 ( 포인터로관리 ) unsigned short int *ppointer ; ppointer = new unsigned short int ; *ppointer = 72; std::cout << *ppointer ; short int *ppointer = new short int ; *ppointer = 72; std::cout << *ppointer ; int num ; std::cin >> num ; int *array = new int[num] ; 11

12 자유기억공간할당및해제 (cont.) 해제 ( delete ) 자유공간의메모리는 ( 스택에저장된지역변수와달리 ) 자동소멸되지않음 강제적인해제필요 delete 포인터 ; delete ppointer ; 메모리누출 ( memory leak ) int *ppointer = new int ; *ppointer = 72; ppointer = new int ; *ppointer = 84; delete ppointer ; 앞선자유기억공간을해제할방법없음 12

13 #include <iostream> int main() using std::cout; list 8.4 int localvariable = 5; int * plocal = &localvariable; int * pheap = new int; *pheap = 7; cout << "localvariable: " << localvariable << "\n"; cout << "*plocal: " << *plocal << "\n"; cout << "*pheap: " << *pheap << "\n"; delete pheap; pheap = new int; *pheap = 9; cout << "*pheap: " << *pheap << "\n"; delete pheap; return 0; 13

14 자유기억장소에객체만들기 / 지우기 만들기 Cat *pcat = new Cat ; 지우기 delete pcat ; 리스트 8.5 자료멤버에접근 (*pcat).getage( ) ; pcat GetAge( ) ; 14

15 #include <iostream> class SimpleCat public: SimpleCat(); ~SimpleCat(); private: int itsage; ; list 8.5 SimpleCat::SimpleCat() std::cout << "Constructor called.\n"; itsage = 1; SimpleCat::~SimpleCat() std::cout << "Destructor called.\n"; 15

16 int main() std::cout << "SimpleCat Frisky...\n"; SimpleCat Frisky; std::cout << "SimpleCat *prags = new SimpleCat...\n"; SimpleCat * prags = new SimpleCat; std::cout << "delete prags...\n"; delete prags; std::cout << "Exiting, watch Frisky go...\n"; return 0; 16

17 #include <iostream> list 8.6 class SimpleCat public: SimpleCat() itsage = 2; ~SimpleCat() int GetAge() const return itsage; void SetAge(int age) itsage = age; private: int itsage; ; int main() SimpleCat * Frisky = new SimpleCat; std::cout << "Frisky is " << Frisky->GetAge() << " years old\n"; Frisky->SetAge(5); std::cout << "Frisky is " << Frisky->GetAge() << " years old\n"; delete Frisky; return 0; 17

18 Class 멤버자료가자유기억공간을가리키는포인터 클래스의생성자 ( 또는메소드 ) 자유기억공간할당 클래스의소멸자 자유기억공간해제 18

19 #include <iostream> class SimpleCat public: SimpleCat(); ~SimpleCat(); int GetAge() const return *itsage; void SetAge(int age) *itsage = age; int GetWeight() const return *itsweight; void setweight (int weight) *itsweight = weight; private: int * itsage; int * itsweight; ; SimpleCat::SimpleCat() itsage = new int(2); itsweight = new int(5); list

20 SimpleCat::~SimpleCat() delete itsage; delete itsweight; int main() SimpleCat *Frisky = new SimpleCat; std::cout << "Frisky is " << Frisky->GetAge() << " years old\n"; Frisky->SetAge(5); std::cout << "Frisky is " << Frisky->GetAge() << " years old\n"; delete Frisky; return 0; 20

21 this 포인터 this 포인터 그개체를가리키는포인터 모든클래스멤버함수가가지는숨겨진매개변수 컴파일러가자동적으로생성과삭제해줌 21

22 #include <iostream.h> class Rectangle public: Rectangle(); ~Rectangle(); list 8.8 void SetLength(int length) this->itslength = length; int GetLength() const return this->itslength; void SetWidth(int width) itswidth = width; int GetWidth() const return itswidth; private: int itslength; int itswidth; ; 22

23 Rectangle::Rectangle() itswidth = 5; itslength = 10; Rectangle::~Rectangle() int main() Rectangle therect; cout << "therect is " << therect.getlength() << " feet long.\n"; cout << "therect is " << therect.getwidth() << " feet wide.\n"; therect.setlength(20); therect.setwidth(10); cout << "therect is " << therect.getlength() << " feet long.\n"; cout << "therect is " << therect.getwidth() << " feet wide.\n"; return 0; 23

24 실종된포인터 메모리해제 (delete) 후포인터를다시사용 논리적에러발생 메모리해제후가능한포인터를널 (null) 로지정 24

25 typedef unsigned short int USHORT; #include <iostream> list 8.9 int main() USHORT * pint = new USHORT; *pint = 10; std::cout << "*pint: " << *pint << std::endl; delete pint; long * plong = new long; *plong = 90000; std::cout << "*plong: " << *plong << std::endl; *pint = 20; // deleted! std::cout << "*pint: " << *pint << std::endl; std::cout << "*plong: " << *plong << std::endl; delete plong; return 0; 25

26 const 포인터 const 의오른쪽항을상수로간주 const int *pone ; int * const ptwo ; const int * const pthree ; pone : 상수형 (int) 에대한포인터 int val = 5 ; const int * pone = &val ; val = 7 ; pone *pone = 10 ; (X) ptwo : 상수포인터 int a = 5, b = 7; int * const ptwo = &a ; *ptwo = 10; pone *ptwo = &b ; (X) 26

27 const 포인터 (cont.) const 객체에대한포인터를선언하면포인터가호출할수있는메소드는 const 메소드뿐 27

28 #include <iostream> using namespace std; list 8.10 class Rectangle public: Rectangle(); ~Rectangle(); void SetLength(int length) itslength = length; int GetLength() const return itslength; void SetWidth(int width) itswidth = width; int GetWidth() const return itswidth; private: int itslength; int itswidth; ; Rectangle::Rectangle() itswidth = 5; itslength = 10; Rectangle::~Rectangle() 28

29 int main() Rectangle* prect = new Rectangle; const Rectangle * pconstrect = new Rectangle; Rectangle * const pconstptr = new Rectangle; cout << "prect width: " << prect->getwidth() << " feet\n"; cout << "pconstrect width: " << pconstrect->getwidth() << " feet\n"; cout << "pconstptr width: " << pconstptr->getwidth() << " feet\n"; prect->setwidth(10); // pconstrect->setwidth(10); pconstptr->setwidth(10); cout << "prect width: " << prect->getwidth() << " feet\n"; cout << "pconstrect width: " << pconstrect->getwidth() << " feet\n"; cout << "pconstptr width: " << pconstptr->getwidth() << " feet\n"; return 0; 29

<4D F736F F F696E74202D2036C0CFC2B05FB0B4C3BCC1F6C7E2C7C1B7CEB1D7B7A1B9D62E707074>

<4D F736F F F696E74202D2036C0CFC2B05FB0B4C3BCC1F6C7E2C7C1B7CEB1D7B7A1B9D62E707074> 객체지향프로그램밍 (Object-Oriented Programming) 1 C++ popular C 객체지향 (object oriented) C++ C : 상위계층언어특징 + 어셈블리언어특징 C++ : 소프트웨어개발플랫폼에객체지향개념제공 객체지향 : 자료와이들자료를어떻게다룰것인지따로생각하지않고단지하나의사물로생각 형 변수가사용하는메모리크기 변수가가질수있는정보

More information

Microsoft PowerPoint - 9ÀÏ°_ÂüÁ¶ÀÚ.ppt

Microsoft PowerPoint - 9ÀÏ°_ÂüÁ¶ÀÚ.ppt 참조자 - 참조자란무엇인가? - 참조자는어떻게만들고사용하는가? - 참조자는포인터와무엇이다른가? 1 참조자 (reference) 란? 참조자 : 객체 ( 타겟 ) 에대한다른이름 ( 별칭 ) 참조자의변화는타겟의변화 참조자만들고반드시초기화 참조자생성 형참조연산자 (&) 참조자이름 = 초기화타겟명 모든항목필수 예 ) int &rsomeref = someint ; 참조자에대한주소연산자

More information

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt 변수와상수 1 변수란무엇인가? 변수 : 정보 (data) 를저장하는컴퓨터내의특정위치 ( 임시저장공간 ) 메모리, register 메모리주소 101 번지 102 번지 변수의크기에따라 주로 byte 단위 메모리 2 기본적인변수형및변수의크기 변수의크기 해당컴퓨터에서는항상일정 컴퓨터마다다를수있음 short

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 5 장생성자와접근제어 1. 객체지향기법을이해한다. 2. 클래스를작성할수있다. 3. 클래스에서객체를생성할수있다. 4. 생성자를이용하여객체를초기화할수 있다. 5. 접근자와설정자를사용할수있다. 이번장에서만들어볼프로그램 생성자 생성자 (constructor) 는초기화를담당하는함수 생성자가필요한이유 #include using namespace

More information

슬라이드 1

슬라이드 1 정적메모리할당 (Static memory allocation) 일반적으로프로그램의실행에필요한메모리 ( 변수, 배열, 객체등 ) 는컴파일과정에서결정되고, 실행파일이메모리에로드될때할당되며, 종료후에반환됨 동적메모리할당 (Dynamic memory allocation) 프로그램의실행중에필요한메모리를할당받아사용하고, 사용이끝나면반환함 - 메모리를프로그램이직접관리해야함

More information

Microsoft PowerPoint - additional01.ppt [호환 모드]

Microsoft PowerPoint - additional01.ppt [호환 모드] 1.C 기반의 C++ part 1 함수 오버로딩 (overloading) 디폴트매개변수 (default parameter) 인-라인함수 (in-line function) 이름공간 (namespace) Jong Hyuk Park 함수 Jong Hyuk Park 함수오버로딩 (overloading) 함수오버로딩 (function overloading) C++ 언어에서는같은이름을가진여러개의함수를정의가능

More information

Microsoft PowerPoint - chap06-2pointer.ppt

Microsoft PowerPoint - chap06-2pointer.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-2 참고자료 포인터 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 포인터의정의와사용 변수를선언하는것은메모리에기억공간을할당하는것이며할당된이후에는변수명으로그기억공간을사용한다. 할당된기억공간을사용하는방법에는변수명외에메모리의실제주소값을사용하는것이다.

More information

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout << " 양수입력 : "; cin >> *p; if (*p <= 0) cout << " 양수를입력해야합니다 " << endl; return; 동적할

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout <<  양수입력 : ; cin >> *p; if (*p <= 0) cout <<  양수를입력해야합니다  << endl; return; 동적할 15 장기타주제들 auto_ptr 변환함수 cast 연산자에의한명시적형변환실행시간타입정보알아내기 (RTTI) C++ 프로그래밍입문 1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout > *p; if (*p

More information

C++ Programming

C++ Programming C++ Programming 연산자다중정의 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 연산자다중정의 C++ 스타일의문자열 2 연산자다중정의 연산자다중정의 단항연산자다중정의 이항연산자다중정의 cin, cout 그리고 endl C++ 스타일의문자열 3 연산자다중정의 연산자다중정의 (Operator

More information

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 5 강. 배열, 포인터, 참조목차 배열 포인터 C++ 메모리구조 주소연산자 포인터 포인터연산 배열과포인터 메모리동적할당 문자열 참조 1 /20 5 강. 배열, 포인터, 참조배열 배열 같은타입의변수여러개를하나의변수명으로처리 int Ary[10]; 총 10 개의변수 : Ary[0]~Ary[9]

More information

Microsoft PowerPoint - Chapter 6.ppt

Microsoft PowerPoint - Chapter 6.ppt 6.Static 멤버와 const 멤버 클래스와 const 클래스와 static 연결리스트프로그램예 Jong Hyuk Park 클래스와 const Jong Hyuk Park C 의 const (1) const double PI=3.14; PI=3.1415; // 컴파일오류 const int val; val=20; // 컴파일오류 3 C 의 const (1)

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

More information

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a 6 장복사생성자 객체의생성과대입객체의값에의한전달복사생성자디폴트복사생성자복사생성자의재정의객체의값에의한반환임시객체 C++ 프로그래밍입문 1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y;

More information

Microsoft PowerPoint - ch07 - 포인터 pm0415

Microsoft PowerPoint - ch07 - 포인터 pm0415 2015-1 프로그래밍언어 7. 포인터 (Pointer), 동적메모리할당 2015 년 4 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) Outline 포인터 (pointer) 란? 간접참조연산자

More information

PowerPoint Presentation

PowerPoint Presentation Class - Property Jo, Heeseung 목차 section 1 클래스의일반구조 section 2 클래스선언 section 3 객체의생성 section 4 멤버변수 4-1 객체변수 4-2 클래스변수 4-3 종단 (final) 변수 4-4 멤버변수접근방법 section 5 멤버변수접근한정자 5-1 public 5-2 private 5-3 한정자없음

More information

11장 포인터

11장 포인터 누구나즐기는 C 언어콘서트 제 9 장포인터 이번장에서학습할내용 포인터이란? 변수의주소 포인터의선언 간접참조연산자 포인터연산 포인터와배열 포인터와함수 이번장에서는포인터의기초적인지식을학습한다. 포인터란? 포인터 (pointer): 주소를가지고있는변수 메모리의구조 변수는메모리에저장된다. 메모리는바이트단위로액세스된다. 첫번째바이트의주소는 0, 두번째바이트는 1, 변수와메모리

More information

Microsoft PowerPoint - additional07.ppt [호환 모드]

Microsoft PowerPoint - additional07.ppt [호환 모드] 보충자료 7. 상속 (inheritance) 의이해 상속의기본개념 상속의생성자, 소멸자 protected 멤버 Jong Hyuk Park 상속의기본개념 Jong Hyuk Park 상속의기본개념 상속의예 1 " 철수는아버지로부터좋은목소리와큰키를물려 받았다." 상속의예 2 "Student 클래스가 Person 클래스를상속한다." 아버지 Person 철수 Stduent

More information

C++ Programming

C++ Programming C++ Programming 상속과다형성 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 상속의이해 상속과다형성 다중상속 2 상속과다형성 객체의이해 상속클래스의객체의생성및소멸 상속의조건 상속과다형성 다중상속 3 상속의이해 상속 (Inheritance) 클래스에구현된모든특성 ( 멤버변수와멤버함수 )

More information

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

More information

Microsoft PowerPoint - C++ 5 .pptx

Microsoft PowerPoint - C++ 5 .pptx C++ 언어프로그래밍 한밭대학교전자. 제어공학과이승호교수 연산자중복 (operator overloading) 이란? 2 1. 연산자중복이란? 1) 기존에미리정의되어있는연산자 (+, -, /, * 등 ) 들을프로그래머의의도에맞도록새롭게정의하여사용할수있도록지원하는기능 2) 연산자를특정한기능을수행하도록재정의하여사용하면여러가지이점을가질수있음 3) 하나의기능이프로그래머의의도에따라바뀌어동작하는다형성

More information

PowerPoint Template

PowerPoint Template 7. 상속 (inheritance) 의이해 상속의기본개념 상속의생성자, 소멸자 protected 멤버 Jong Hyuk Park 상속의기본개념 Jong Hyuk Park 상속의기본개념 상속의예 1 " 철수는아버지로부터좋은목소리와큰키를물려받았다." 상속의예 2 "Student 클래스가 Person 클래스를상속한다." 아버지 Person 철수 Stduent 3

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 11 장상속 1. 상속의개념을이해한다. 2. 상속을이용하여자식클래스를작성할수있다. 3. 상속과접근지정자와의관계를이해한다. 4. 상속시생성자와소멸자가호출되는순서를이해한다. 이번장에서만들어볼프로그램 class Circle { int x, y; int radius;... class Rect { int x, y; int width, height;... 중복 상속의개요

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 System Software Experiment 1 Lecture 5 - Array Spring 2019 Hwansoo Han (hhan@skku.edu) Advanced Research on Compilers and Systems, ARCS LAB Sungkyunkwan University http://arcs.skku.edu/ 1 배열 (Array) 동일한타입의데이터가여러개저장되어있는저장장소

More information

C++ Programming

C++ Programming C++ Programming 예외처리 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 예외처리 2 예외처리 예외처리 C++ 의예외처리 예외클래스와객체 3 예외처리 예외를처리하지않는프로그램 int main() int a, b; cout > a >> b; cout

More information

PowerPoint Presentation

PowerPoint Presentation public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum +

More information

Microsoft PowerPoint - additional08.ppt [호환 모드]

Microsoft PowerPoint - additional08.ppt [호환 모드] 8. 상속과다형성 (polymorphism) 상속된객체와포인터 / 참조자의관계 정적바인딩과동적바인딩 virtual 소멸자 Jong Hyuk Park 상속의조건 public 상속은 is-a 관계가성립되도록하자. 일반화 ParttimeStd 구체화 2 상속의조건 잘못된상속의예 현실세계와완전히동떨어진모델이형성됨 3 상속의조건 HAS-A( 소유 ) 관계에의한상속!

More information

C++ Programming

C++ Programming C++ Programming 클래스와데이터추상화 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 객체지향프로그래밍 클래스와객체 2 객체지향프로그래밍 객체지향언어 (Object-Oriented Language) 프로그램을명령어의목록으로보는시각에서벗어나여러개의 독립된단위, 즉 객체 (Object) 들의모임으로파악

More information

Microsoft PowerPoint - additional06.ppt [호환 모드]

Microsoft PowerPoint - additional06.ppt [호환 모드] 보조자료 6.Static 멤버와 const 멤버 클래스와 const 클래스와 static 연결리스트프로그램예 Jong Hyuk Park 클래스와 const Jong Hyuk Park 복습 : Const 키워드왜사용? C 의 const (1) const double PI=3.14; PI=3.1415; // 컴파일오류 const int val; val=20; //

More information

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 9 강. 클래스의활용목차 멤버함수의외부정의 this 포인터 friend 선언 static 멤버 임시객체 1 /17 9 강. 클래스의활용멤버함수의외부정의 멤버함수정의구현방법 내부정의 : 클래스선언내에함수정의구현 외부정의 클래스선언 : 함수프로토타입 멤버함수정의 : 클래스선언외부에구현

More information

3. 1 포인터란 3. 2 포인터변수의선언과사용 3. 3 다차원포인터변수의선언과사용 3. 4 주소의가감산 3. 5 함수포인터

3. 1 포인터란 3. 2 포인터변수의선언과사용 3. 3 다차원포인터변수의선언과사용 3. 4 주소의가감산 3. 5 함수포인터 - Part2-3 3. 1 포인터란 3. 2 포인터변수의선언과사용 3. 3 다차원포인터변수의선언과사용 3. 4 주소의가감산 3. 5 함수포인터 3.1 포인터란 ü ü ü. ü. ü. ü ( ) ? 3.1 ü. ü C ( ).? ü ü PART2-4 ü ( ) PART3-4 3.2 포인터변수의선언과사용 3.2 포인터 변수의 선언과 사용 (1/8) 포인터 변수의

More information

Microsoft PowerPoint - Chapter 1-rev

Microsoft PowerPoint - Chapter 1-rev 1.C 기반의 C++ part 1 스트림입출력 함수 오버로딩 (overloading) 디폴트매개변수 (default parameter) 인-라인함수 (in-line function) 이름공간 (namespace) Jong Hyuk Park 스트림입출력 Jong Hyuk Park printf 와 scanf 출력의기본형태 : 과거스타일! iostream.h 헤더파일의포함

More information

(Microsoft Word - \301\337\260\243\260\355\273\347.docx)

(Microsoft Word - \301\337\260\243\260\355\273\347.docx) 내장형시스템공학 (NH466) 중간고사 학번 : 이름 : 문제 배점 점수 1 20 2 20 3 20 4 20 5 10 6 10 7 15 8 20 9 15 합계 150 1. (20 점 ) 다음용어에대해서설명하시오. (1) 정보은닉 (Information Hiding) (2) 캡슐화 (Encapsulation) (3) 오버로딩 (Overloading) (4) 생성자

More information

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Function) 1. 함수의개념 입력에대해적절한출력을발생시켜주는것 내가 ( 프로그래머 ) 작성한명령문을연산, 처리, 실행해주는부분 ( 모듈 ) 자체적으로실행되지않으며,

More information

untitled

untitled int i = 10; char c = 69; float f = 12.3; int i = 10; char c = 69; float f = 12.3; printf("i : %u\n", &i); // i printf("c : %u\n", &c); // c printf("f : %u\n", &f); // f return 0; i : 1245024 c : 1245015

More information

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public Chapter 9 Lab 문제정답 1. public class Circle private double radius; static final double PI=3.141592; // PI 이름으로 3.141592 로초기화된정적상수 (1) public Circle(double r) radius = r; (2) public double getradius() return

More information

080629_CFP °ø°³¿ë.hwp

080629_CFP °ø°³¿ë.hwp int deleteq(int *front, rear) int item; if ( ( 가 ) ) retuen queue_empty; ( ( 나 ) ) ; return queue[*front]; 주어진문제의해에접근한결과, 즉근사해를출력하거나혹은일정확률이상의정확한해를구할수있는알고리즘으로, 이알고리즘은주어진문제에대한근사해로만족할수있거나, 간혹틀린해를출력하는경우를허용할수있는경우활용할수있다.

More information

(Microsoft PowerPoint - 07\300\345.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - 07\300\345.ppt [\310\243\310\257 \270\360\265\345]) 클래스의응용 클래스를자유자재로사용하자. 이장에서다룰내용 1 객체의치환 2 함수와클래스의상관관계 01_ 객체의치환 객체도변수와마찬가지로치환이가능하다. 기본예제 [7-1] 객체도일반변수와마찬가지로대입이가능하다. 기본예제 [7-2] 객체의치환시에는조심해야할점이있다. 복사생성자의필요성에대하여알아보자. [ 기본예제 7-1] 클래스의치환 01 #include

More information

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2

목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 제 8 장. 포인터 목차 포인터의개요 배열과포인터 포인터의구조 실무응용예제 C 2 포인터의개요 포인터란? 주소를변수로다루기위한주소변수 메모리의기억공간을변수로써사용하는것 포인터변수란데이터변수가저장되는주소의값을 변수로취급하기위한변수 C 3 포인터의개요 포인터변수및초기화 * 변수데이터의데이터형과같은데이터형을포인터 변수의데이터형으로선언 일반변수와포인터변수를구별하기위해

More information

Microsoft PowerPoint - 03_(C_Programming)_(Korean)_Pointers

Microsoft PowerPoint - 03_(C_Programming)_(Korean)_Pointers C Programming 포인터 (Pointers) Seo, Doo-Ok Clickseo.com clickseo@gmail.com 목 차 포인터의이해 다양한포인터 2 포인터의이해 포인터의이해 포인터변수선언및초기화 포인터연산 다양한포인터 3 주소연산자 ( & ) 포인터의이해 (1/4) 변수와배열원소에만적용한다. 산술식이나상수에는주소연산자를사용할수없다. 레지스터변수또한주소연산자를사용할수없다.

More information

PowerPoint Template

PowerPoint Template 1.C 기반의 C++ 스트림입출력 함수 오버로딩 (overloading) 디폴트매개변수 (default parameter) 인-라인함수 (in-line function) 이름공간 (namespace) Jong Hyuk Park 스트림입출력 Jong Hyuk Park printf 와 scanf 출력의기본형태 iostream 헤더파일의포함 HelloWorld2.cpp

More information

Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - chap10-함수의활용.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 중 값에 의한 전달 방법과

More information

C프로-3장c03逞풚

C프로-3장c03逞풚 C h a p t e r 03 C++ 3 1 9 4 3 break continue 2 110 if if else if else switch 1 if if if 3 1 1 if 2 2 3 if if 1 2 111 01 #include 02 using namespace std; 03 void main( ) 04 { 05 int x; 06 07

More information

4 장클래스와객체 클래스와객체 public과 private 구조체와클래스객체의생성과생성자객체의소멸과소멸자생성자와소멸자의호출순서디폴트생성자와디폴트소멸자멤버초기화멤버함수의외부정의멤버함수의인라인함수선언 C++ 프로그래밍입문

4 장클래스와객체 클래스와객체 public과 private 구조체와클래스객체의생성과생성자객체의소멸과소멸자생성자와소멸자의호출순서디폴트생성자와디폴트소멸자멤버초기화멤버함수의외부정의멤버함수의인라인함수선언 C++ 프로그래밍입문 4 장클래스와객체 클래스와객체 public과 private 구조체와클래스객체의생성과생성자객체의소멸과소멸자생성자와소멸자의호출순서디폴트생성자와디폴트소멸자멤버초기화멤버함수의외부정의멤버함수의인라인함수선언 C++ 프로그래밍입문 1. 클래스와객체 추상데이터형 : 속성 (attribute) + 메서드 (method) 예 : 자동차의속성과메서드 C++ : 주로 class

More information

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 8 장클래스와객체 I 이번장에서학습할내용 클래스와객체 객체의일생직접 메소드클래스를 필드작성해 UML 봅시다. QUIZ 1. 객체는 속성과 동작을가지고있다. 2. 자동차가객체라면클래스는 설계도이다. 먼저앞장에서학습한클래스와객체의개념을복습해봅시다. 클래스의구성 클래스 (class) 는객체의설계도라할수있다. 클래스는필드와메소드로이루어진다.

More information

1. 표준입출력 C++ : C의모든라이브러리를포함 printf, scanf 함수사용가능예 : int, double, 문자열값을입력받고출력하기 #include <cstdio> int ivar; double dvar; char str[20]; printf("int, dou

1. 표준입출력 C++ : C의모든라이브러리를포함 printf, scanf 함수사용가능예 : int, double, 문자열값을입력받고출력하기 #include <cstdio> int ivar; double dvar; char str[20]; printf(int, dou 2 장더나은 C 로서의 C++ (1) 표준입출력네임스페이스 ( 고전 C++ 와표준 C++) 함수오버로딩디폴트매개변수 new와 delete bool 자료형 C++ is not C C++ 프로그래밍입문 1. 표준입출력 C++ : C의모든라이브러리를포함 printf, scanf 함수사용가능예 : int, double, 문자열값을입력받고출력하기 #include

More information

PowerPoint Template

PowerPoint Template 16-1. 보조자료템플릿 (Template) 함수템플릿 클래스템플릿 Jong Hyuk Park 함수템플릿 Jong Hyuk Park 함수템플릿소개 함수템플릿 한번의함수정의로서로다른자료형에대해적용하는함수 예 int abs(int n) return n < 0? -n : n; double abs(double n) 함수 return n < 0? -n : n; //

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 3 장함수와문자열 1. 함수의기본적인개념을이해한다. 2. 인수와매개변수의개념을이해한다. 3. 함수의인수전달방법 2가지를이해한다 4. 중복함수를이해한다. 5. 디폴트매개변수를이해한다. 6. 문자열의구성을이해한다. 7. string 클래스의사용법을익힌다. 이번장에서만들어볼프로그램 함수란? 함수선언 함수호출 예제 #include using

More information

chap10.PDF

chap10.PDF 10 C++ Hello!! C C C++ C++ C++ 2 C++ 1980 Bell Bjarne Stroustrup C++ C C++ C, C++ C C 3 C C++ (prototype) (type checking) C C++ : C++ 4 C C++ (prototype) (type checking) [ 10-1] #include extern

More information

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 6 강. 함수와배열, 포인터, 참조목차 함수와포인터 주소값의매개변수전달 주소의반환 함수와배열 배열의매개변수전달 함수와참조 참조에의한매개변수전달 참조의반환 프로그래밍연습 1 /15 6 강. 함수와배열, 포인터, 참조함수와포인터 C++ 매개변수전달방법 값에의한전달 : 변수값,

More information

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++,

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++, Level 1은객관식사지선다형으로출제예정 1. 다음은 POST(Post of Sales Terminal) 시스템의한콜레보레이션다이어그램이다. POST 객체의 enteritem(upc, qty) 와 Sale 객체의 makellineitem(spec,qty) 를 Java 또는 C ++, C # 언어로구현하시오. 각메소드구현과관련하여각객체내에필요한선언이있으면선언하시오.

More information

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning C Programming Practice (II) Contents 배열 문자와문자열 구조체 포인터와메모리관리 구조체 2/17 배열 (Array) (1/2) 배열 동일한자료형을가지고있으며같은이름으로참조되는변수들의집합 배열의크기는반드시상수이어야한다. type var_name[size]; 예 ) int myarray[5] 배열의원소는원소의번호를 0 부터시작하는색인을사용

More information

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770>

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770> 연습문제해답 5 4 3 2 1 0 함수의반환값 =15 5 4 3 2 1 0 함수의반환값 =95 10 7 4 1-2 함수의반환값 =3 1 2 3 4 5 연습문제해답 1. C 언어에서의배열에대하여다음중맞는것은? (1) 3차원이상의배열은불가능하다. (2) 배열의이름은포인터와같은역할을한다. (3) 배열의인덱스는 1에서부터시작한다. (4) 선언한다음, 실행도중에배열의크기를변경하는것이가능하다.

More information

Microsoft PowerPoint - 제11장 포인터

Microsoft PowerPoint - 제11장 포인터 쉽게풀어쓴 C 언어 Express 제 11 장포인터 이번장에서학습할내용 포인터이란? 변수의주소 포인터의선언 간접참조연산자 포인터연산 포인터와배열 포인터와함수 이번장에서는포인터의기초적인지식을학습한다. 포인터란? 포인터 (pointer): 주소를가지고있는변수 1003 1004 1005 영화관 1002 1006 1001 포인터 (pointer) 1007 메모리의구조

More information

Microsoft PowerPoint - 제11장 포인터(강의)

Microsoft PowerPoint - 제11장 포인터(강의) 쉽게풀어쓴 C 언어 Express 제 11 장포인터 이번장에서학습할내용 포인터이란? 변수의주소 포인터의선언 간접참조연산자 포인터연산 포인터와배열 포인터와함수 이번장에서는포인터의기초적인지식을학습한다. 포인터란? 포인터 (pointer): 주소를가지고있는변수 1003 1004 1005 영화관 1002 1006 1001 포인터 (pointer) 1007 메모리의구조

More information

Microsoft PowerPoint - chap03-변수와데이터형.pptx

Microsoft PowerPoint - chap03-변수와데이터형.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num %d\n", num); return 0; } 1 학습목표 의 개념에 대해 알아본다.

More information

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

Microsoft PowerPoint 자바-기본문법(Ch2).pptx 자바기본문법 1. 기본사항 2. 자료형 3. 변수와상수 4. 연산자 1 주석 (Comments) 이해를돕기위한설명문 종류 // /* */ /** */ 활용예 javadoc HelloApplication.java 2 주석 (Comments) /* File name: HelloApplication.java Created by: Jung Created on: March

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 14. 포인터와함수에대한이해 2013.10.09. 오병우 컴퓨터공학과 14-1 함수의인자로배열전달 기본적인인자의전달방식 값의복사에의한전달 val 10 a 10 11 Department of Computer Engineering 2 14-1 함수의인자로배열전달 배열의함수인자전달방식 배열이름 ( 배열주소, 포인터 ) 에의한전달 #include

More information

PowerPoint Presentation

PowerPoint Presentation 컴퓨터프로그래밍 Computer Programming 08 포인터기초 목차 1. 포인터변수와선언 2. 간접연산자 * 와포인터연산 3. 포인터형변환과다중포인터 컴퓨터프로그래밍 (Computer Programming) - 08 포인터기초 3 1. 포인터변수와선언 주소개념 주소 address 메모리공간은 8비트인 1 바이트마다순차적인고유한번호 메모리주소는저장장소인변수이름과함께기억장소를참조하는또다른방법

More information

Lab 3. 실습문제 (Single linked list)_해답.hwp

Lab 3. 실습문제 (Single linked list)_해답.hwp Lab 3. Singly-linked list 의구현 실험실습일시 : 2009. 3. 30. 담당교수 : 정진우 담당조교 : 곽문상 보고서제출기한 : 2009. 4. 5. 학과 : 학번 : 성명 : 실습과제목적 : 이론시간에배운 Singly-linked list를실제로구현할수있다. 실습과제내용 : 주어진소스를이용해 Singly-linked list의각함수를구현한다.

More information

JAVA PROGRAMMING 실습 05. 객체의 활용

JAVA PROGRAMMING 실습 05. 객체의 활용 public class Person{ public String name; public int age; } public Person(){ } public Person(String s, int a){ name = s; age = a; } public String getname(){ return name; } @ 객체의선언 public static void main(string

More information

Microsoft PowerPoint - chap11-포인터의활용.pptx

Microsoft PowerPoint - chap11-포인터의활용.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 포인터를 사용하는 다양한 방법에

More information

gnu-lee-oop-kor-lec06-3-chap7

gnu-lee-oop-kor-lec06-3-chap7 어서와 Java 는처음이지! 제 7 장상속 Super 키워드 상속과생성자 상속과다형성 서브클래스의객체가생성될때, 서브클래스의생성자만호출될까? 아니면수퍼클래스의생성자도호출되는가? class Base{ public Base(String msg) { System.out.println("Base() 생성자 "); ; class Derived extends Base

More information

(Microsoft PowerPoint - 11\300\345.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - 11\300\345.ppt [\310\243\310\257 \270\360\265\345]) 입출력 C++ 의효율적인입출력방법을배워보자. 이장에서다룰내용 1 cin 과 cout 을이용한입출력 2 입출력연산자중복 3 조작자생성 4 파일입출력 01_cin 과 cout 을이용한입출력 포맷입출력 C++ 의표준입출력은 cin, cout 을사용한다. C 의 printf 는함수이므로매번여러인자를입력해줘야하지만, cin/cout 에서는형식을한번만정의하면계속사용할수있다.

More information

The C++ Programming Language 5 장포인터, 배열, 구조체 5.9 연습문제 다음의선언문을순서대로작성해보자. 문자에대한포인터, 10개정수의배열, 10개정수의배열의참조자, 문자열의배열에대한포인터, 문자에대한포인터에대한포인터, 상수정수, 상수

The C++ Programming Language 5 장포인터, 배열, 구조체 5.9 연습문제 다음의선언문을순서대로작성해보자. 문자에대한포인터, 10개정수의배열, 10개정수의배열의참조자, 문자열의배열에대한포인터, 문자에대한포인터에대한포인터, 상수정수, 상수 The C++ Programming Language 5 장포인터, 배열, 구조체 5.9 연습문제 5.9.1 다음의선언문을순서대로작성해보자. 문자에대한포인터, 10개정수의배열, 10개정수의배열의참조자, 문자열의배열에대한포인터, 문자에대한포인터에대한포인터, 상수정수, 상수정수에대한포인터, 정수에대한상수포인터. 그리고각각의객체를초기화하자. Ex 문자에대한포인터 char

More information

PowerPoint Template

PowerPoint Template 10 포인터 1 주소 Address( 주소 ) 메모리에는그메모리의저장장소의위치를나타내는주소값 주소 (address) 는 1 바이트마다 1 씩증가하도록메모리에는연속적인번호가구성 2 주소연산자 & & 변수 변수의주소값을알아내려면변수앞에주소연산자 & (ampersand) 를이용 주소값이용장단점 주소값을이용하면보다편리하고융통성있는프로그램이가능 그러나복잡하고어려운단점

More information

C# Programming Guide - Types

C# Programming Guide - Types C# Programming Guide - Types 최도경 lifeisforu@wemade.com 이문서는 MSDN 의 Types 를요약하고보충한것입니다. http://msdn.microsoft.com/enus/library/ms173104(v=vs.100).aspx Types, Variables, and Values C# 은 type 에민감한언어이다. 모든

More information

프입2-강의노트-C++기초

프입2-강의노트-C++기초 Chapter 01. C 언어복습및 C++ 기초 박종혁교수 UCS Lab Tel: 970-6702 Email: jhpark1@seoultech.ac.kr SeoulTech 2018-2 nd 프로그래밍입문 (2) C 언어복습 구조체, 포인터, 기타 01 구조체정의 02 구조체변수정의 03 구조체초기화 구조체 4 구조체의정의 학생의정보를보관하기위한구조체정의 //

More information

chap 5: Trees

chap 5: Trees 5. Threaded Binary Tree 기본개념 n 개의노드를갖는이진트리에는 2n 개의링크가존재 2n 개의링크중에 n + 1 개의링크값은 null Null 링크를다른노드에대한포인터로대체 Threads Thread 의이용 ptr left_child = NULL 일경우, ptr left_child 를 ptr 의 inorder predecessor 를가리키도록변경

More information

Programming hwp

Programming hwp struct MerchandiseTable { CatalogEntry tab[10]; void init(); char const *getname(char const *code); int getprice(char const *code); void MerchandiseTable::init() { strcpy(tab[0].code, "m01"); strcpy(tab[0].name,

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 10 포인터 01 포인터의기본 02 인자전달방법 03 포인터와배열 04 포인터와문자열 변수의주소를저장하는포인터에대해알아본다. 함수의인자를값과주소로전달하는방법을알아본다. 포인터와배열의관계를알아본다. 포인터와문자열의관계를알아본다. 1.1 포인터선언 포인터선언방법 자료형 * 변수명 ; int * ptr; * 연산자가하나이면 1 차원포인터 1 차원포인터는일반변수의주소를값으로가짐

More information

제 11 장포인터 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다.

제 11 장포인터 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 제 11 장포인터 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 포인터이란? 변수의주소 포인터의선언 간접참조연산자 포인터연산 포인터와배열 포인터와함수 이번장에서는포인터의기초적인지식을학습합니다.

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

KNK_C_05_Pointers_Arrays_structures_summary_v02

KNK_C_05_Pointers_Arrays_structures_summary_v02 Pointers and Arrays Structures adopted from KNK C Programming : A Modern Approach 요약 2 Pointers and Arrays 3 배열의주소 #include int main(){ int c[] = {1, 2, 3, 4}; printf("c\t%p\n", c); printf("&c\t%p\n",

More information

Microsoft PowerPoint - lecture2.ppt

Microsoft PowerPoint - lecture2.ppt Overview s & osg::referenced Class & osg::ref_ptr Template Class 개요 OSG OSG::Referenced Class OSG::ref_ptr Template Class 2008년여름박경신 2 스마트포인터 () 는 C++ class 이다. syntax 와 semantics 상일반포인터와같다. memory

More information

윤성우의 열혈 TCP/IP 소켓 프로그래밍

윤성우의 열혈 TCP/IP 소켓 프로그래밍 Chapter 08. 상속과다형성 박종혁교수 UCS Lab Tel: 970-6702 Email: jhpark1@seoultech.ac.kr SeoulTech 2013-2 nd 프로그래밍입문 (2) Chapter 08-1. 객체포인터의참조관계 3 상속된객체와포인터관계 객체포인터 객체의주소값을저장할수있는포인터 AAA 클래스의포인터는 AAA 객체의주소뿐만아니라 AAA

More information

JVM 메모리구조

JVM 메모리구조 조명이정도면괜찮조! 주제 JVM 메모리구조 설미라자료조사, 자료작성, PPT 작성, 보고서작성. 발표. 조장. 최지성자료조사, 자료작성, PPT 작성, 보고서작성. 발표. 조원 이용열자료조사, 자료작성, PPT 작성, 보고서작성. 이윤경 자료조사, 자료작성, PPT작성, 보고서작성. 이수은 자료조사, 자료작성, PPT작성, 보고서작성. 발표일 2013. 05.

More information

Microsoft PowerPoint 장강의노트.ppt

Microsoft PowerPoint 장강의노트.ppt 클래스와객체 클래스와객체 객체 : 우리주변의어떤대상의모델 - 예 : 사람, 차, TV, 개 객체 = 상태 (state) + 행동 (behavior) - 예 : 개의상태 - 종자, 이름, 색개의행동 - 짖다, 가져오다 상태는변수로행동은메소드로나타냄 객체는클래스에의해정의된다. 클래스는객체가생성되는틀혹은청사진이다. 2 예 : 클래스와객체 질문 : 클래스와객체의다른예는?

More information

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 (   ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각 JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( http://java.sun.com/javase/6/docs/api ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각선의길이를계산하는메소드들을작성하라. 직사각형의가로와세로의길이는주어진다. 대각선의길이는 Math클래스의적절한메소드를이용하여구하라.

More information

Microsoft PowerPoint - additional03.ppt [호환 모드]

Microsoft PowerPoint - additional03.ppt [호환 모드] 3. 클래스의기본 객체지향프로그래밍소개 구조체와클래스 클래스의정의 Jong Hyuk Park 객체지향프로그래밍소개 Jong Hyuk Park 구조적프로그래밍개념 기존 C와같은구조적프로그래밍언어는동작되는자료와처리동작자체를서로별도로구분 처리동작과자료사이의관계가서로밀접한연관성을갖지못함 프로그램이커지거나복잡해지면프로그램이혼란스럽게되어에러를찾는디버깅및프로그램의유지보수가어려워짐

More information

C++ Programming

C++ Programming C++ Programming C++ 스타일의입출력 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 C 스타일의입출력 C++ 스타일의입출력 2 C 스타일의입출력 #include C 스타일의입출력 int main() { int a, b, c; printf(" 세개의정수입력 : "); scanf("%d

More information

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100 2015-1 프로그래밍언어 9. 연결형리스트, Stack, Queue 2015 년 5 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) 연결리스트 (Linked List) 연결리스트연산 Stack

More information

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx #include int main(void) { int num; printf( Please enter an integer "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 을 작성하면서 C 프로그램의

More information

Microsoft PowerPoint - chap-11.pptx

Microsoft PowerPoint - chap-11.pptx 쉽게풀어쓴 C 언어 Express 제 11 장포인터 컴퓨터프로그래밍기초 이번장에서학습할내용 포인터이란? 변수의주소 포인터의선언 간접참조연산자 포인터연산 포인터와배열 포인터와함수 이번장에서는포인터의기초적인지식을학습한다. 컴퓨터프로그래밍기초 2 포인터란? 포인터 (pointer): 주소를가지고있는변수 컴퓨터프로그래밍기초 3 메모리의구조 변수는메모리에저장된다. 메모리는바이트단위로액세스된다.

More information

Microsoft Word - FunctionCall

Microsoft Word - FunctionCall Function all Mechanism /* Simple Program */ #define get_int() IN KEYOARD #define put_int(val) LD A val \ OUT MONITOR int add_two(int a, int b) { int tmp; tmp = a+b; return tmp; } local auto variable stack

More information

The C++ Programming Language 4 장타입과선언 4.11 연습문제 Hello,world! 프로그램을실행시킨다. 프로그램이컴파일되지않으면 B3.1 을참고하자. #include<iostream> //#include 문, 헤더파일, 전처리지시

The C++ Programming Language 4 장타입과선언 4.11 연습문제 Hello,world! 프로그램을실행시킨다. 프로그램이컴파일되지않으면 B3.1 을참고하자. #include<iostream> //#include 문, 헤더파일, 전처리지시 The C++ Programming Language 4 장타입과선언 4.11 연습문제 4.11.1 Hello,world! 프로그램을실행시킨다. 프로그램이컴파일되지않으면 B3.1 을참고하자. #include //#include 문, 헤더파일, 전처리지시자로호칭 using namespace std; //using 키워드를사용하여 std 네임스페이스를사용선언

More information

11장 포인터

11장 포인터 Dynamic Memory and Linked List 1 동적할당메모리의개념 프로그램이메모리를할당받는방법 정적 (static) 동적 (dynamic) 정적메모리할당 프로그램이시작되기전에미리정해진크기의메모리를할당받는것 메모리의크기는프로그램이시작하기전에결정 int i, j; int buffer[80]; char name[] = data structure"; 처음에결정된크기보다더큰입력이들어온다면처리하지못함

More information

윤성우의 열혈 TCP/IP 소켓 프로그래밍

윤성우의 열혈 TCP/IP 소켓 프로그래밍 예외처리 (Exception Handling) 박종혁교수 UCS Lab Tel: 970-6702 Email: jhpark1@seoultech.ac.kr SeoulTech 2012-2 nd 프로그래밍입문 (1) 예외상황과예외처리의이해 3 예외상황을처리하지않았을때의결과 예외상황은프로그램실행중에발생하는문제의상황을의미한다. 예외상황의예나이를입력하라고했는데, 0보다작은값이입력됨.

More information

chap8.PDF

chap8.PDF 8 Hello!! C 2 3 4 struct - {...... }; struct jum{ int x_axis; int y_axis; }; struct - {...... } - ; struct jum{ int x_axis; int y_axis; }point1, *point2; 5 struct {....... } - ; struct{ int x_axis; int

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 13 장파일처리 1. 스트림의개념을이해한다. 2. 객체지향적인방법을사용하여파일입출력을할수있다. 3. 텍스트파일과이진파일의차이점을이해한다. 4. 순차파일과임의접근파일의차이점을이해한다. 이번장에서만들어볼프로그램 스트림 (stream) 스트림 (stream) 은 순서가있는데이터의연속적인흐름 이다. 스트림은입출력을물의흐름처럼간주하는것이다. 입출력관련클래스들 파일쓰기

More information

윤성우의 열혈 TCP/IP 소켓 프로그래밍

윤성우의 열혈 TCP/IP 소켓 프로그래밍 상속의이해 박종혁교수 UCS Lab Tel: 970-6702 Email: jhpark1@seoultech.ac.kr SeoulTech 프로그래밍입문 3 상속의기본개념 상속의예1 " 철수는아버지로부터좋은목소리와큰키를물려받았다." 상속의예2 "Student 클래스가 Person 클래스를상속한다." 아버지 Person 철수 Stduent 4 파생클래스 (derived

More information

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 System call table and linkage v Ref. http://www.ibm.com/developerworks/linux/library/l-system-calls/ - 2 - Young-Jin Kim SYSCALL_DEFINE 함수

More information

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다.

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 이중포인터란무엇인가? 포인터배열 함수포인터 다차원배열과포인터 void 포인터 포인터는다양한용도로유용하게활용될수있습니다. 2 이중포인터

More information

C++ Programming

C++ Programming C++ Programming C 언어에서 C++ 언어로의전환 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 C++ 언어개요 C 언어기반의 C++ 2 C++ 언어개요 C++ 언어개요 C++ 언어의역사및특징 통합개발환경 C 언어기반의 C++ 3 C++ 언어의역사 C++ 언어의역사및특징 1979 년,

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 4 (Object) (Class) (Instance) (Method) (Constructor) Memory 1 UML 1 @ & 1 (Real World) (Software World) @ &.. () () @ & 2 (Real World) (Software World) OOA/ Modeling Abstraction Instantiation

More information

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 13. 포인터와배열! 함께이해하기 2013.10.02. 오병우 컴퓨터공학과 13-1 포인터와배열의관계 Programming in C, 정재은저, 사이텍미디어. 9 장참조 ( 교재의 13-1 은읽지말것 ) 배열이름의정체 배열이름은 Compile 시의 Symbol 로서첫번째요소의주소값을나타낸다. Symbol 로서컴파일시에만유효함 실행시에는메모리에잡히지않음

More information

Data Structure

Data Structure Function & Pointer C- 언어의활용을위한주요기법 (3) Dong Kyue Kim Hanyang University dqkim@hanyang.ac.kr 함수의인자전달 함수의인자전달 함수의인자전달방식 인자전달의기본방식은복사다. 함수호출시전달되는값을매개변수를통해서전달받는데, 이때에값의복사가일어난다. int main(void) int val = 10;

More information

Slide 1

Slide 1 SeoulTech 2011-2 nd 프로그래밍입문 (2) Chapter 11. 분리컴파일과 네임스페이스 박종혁교수 (http://www.parkjonghyuk.net) Tel: 970-6702 Email: jhpark1@snut.ac.kr 분리컴파일 프로그램부분 분리된파일에저장 분리되어컴파일 프로그램이실행되기전에상호간에링크됨 클래스정의 사용프로그램에서분리됨

More information

Microsoft PowerPoint - Chap12-OOP.ppt

Microsoft PowerPoint - Chap12-OOP.ppt 객체지향프로그래밍 (Object Oriented Programming) 12 장강사 강대기 차례 (Agenda) 멤버에대한동적메모리할당 암시적 / 명시적복사생성자 암시적 / 명시적오버로딩대입연산자 생성자에 new 사용하기 static 클래스멤버 객체에위치지정 new 사용하기 객체를지시하는포인터 StringBad 클래스 멤버에포인터사용 str static 멤버

More information

Microsoft PowerPoint - Chapter 10.ppt

Microsoft PowerPoint - Chapter 10.ppt 10. 연산자오버로딩 연산자오버로딩소개 이항연산자오버로딩 단항연산자의오버로딩 cout, cin, endl 구현 배열인덱스연산자오버로딩 대입연산자오버로딩 Jong Hyuk Park 연산자오버로딩소개 Jong Hyuk Park 연산자오버로딩 (operator overloading) C++ 에서는기존의 C 언어에서제공하고있는연산자에대하여그의미를다시부여하는것을 "

More information

15. 윈도 운영체제

15. 윈도 운영체제 한국방송통신대학교 출석수업담당김명진 ( 공학박사 ) 동양미래대학교겸임교수 1. 시작하기 C++ 프로그램의기본구조 동적메모리할당 함수 C++ 프로그램의소스파일 C++ 소스프로그램파일 처리하고자하는작업을수행하는 C++ 프로그램명령어들을담고있는파일파일의확장자 :.cpp,.cxx,.c 등 C++ 헤더파일 클래스, 함수의원형, 매크로, 전역변수, 상수등여러소스파일에공통적으로선언되는내용을담고있는파일단독으로컴파일되지않고,

More information