Presentation is loading. Please wait.

Presentation is loading. Please wait.

C++ Programming ㅎㅎ String OOP Class Constructor & Destructor.

Similar presentations


Presentation on theme: "C++ Programming ㅎㅎ String OOP Class Constructor & Destructor."— Presentation transcript:

1 C++ Programming ㅎㅎ String OOP Class Constructor & Destructor

2 A string is a null terminated array of characters.
C++ strings A string is a null terminated array of characters. null terminated means there is a character at the end of the array that has the value 0 (null). Pointers are often used with strings: char *msg = "RPI"; zero (null) msg 'R‘ 'P‘ 'I‘ 10/2013

3 [Practice 1] <cstring>

4 [Practice 1] <string>

5 Informationhiding, 데이터 은닉
OOP (Object Oriented Programming) OOP? (Object Oriented Programming) To recognize all of the data as an object, an object can be operated independently, while other objects, also available as a component to the program. Programming available as a component of other objects Abstraction, 추상화 Encapsulation, 캡슐화 Informationhiding, 데이터 은닉 Inheritance, 상속 Polymorphism, 다형

6 A C++ class is an object type.
Class: Object Types A C++ class is an object type. Objects are structures that allocate memory during program execution An objects is instance of some class and is created during runtime by special statements When you create the definition of a class you are defining the attributes and behavior of a new type. Attributes are data members. Behavior is defined by methods. 10/2013

7 Class Definition in C++
class Circle { public : double radius; double area() { return radius * radius * 3.141; }; 10/2013

8 Class Circle – Description of Properties
Class: Object Types Class Circle – Description of Properties Circle Attribute radius : double Method area () : double object 1 object 2 object 3 object 4 radius = 2 radius = 12 radius = 3 radius = 7 Instances of Class Circle 10/2013

9 [Practice 2] class declaration

10 [Practice 3] class declaration

11 [Explain 3] class declaration
member variables member functions

12 [Practice 4] Do you want to attack a monster?

13 [Practice 4] Do you want to attack a monster?

14 [Explain 4] Do you want to attack a monster?

15 [Practice 5] Comprehensive class

16 [Practice 5] Comprehensive class…continue

17 [Practice 5] Comprehensive class…continue

18 [Practice 5] Comprehensive class…continue

19 [Explain 5] Comprehensive class…continue

20 Special Member Functions
Constructors: called when a new object is created (instantiated). can be many constructors, each can take different arguments. Destructor: called when an object is eliminated only one, has no arguments. 10/2014

21 [Practice 6] Constructor & Destructor

22 [Practice 6] Constructor & Destructor

23 [Explain 6] Constructor & Destructor

24 [Exercising 1] Student #include <string>으로 사용
Constructors 사용하여 객체 instance 생성

25


Download ppt "C++ Programming ㅎㅎ String OOP Class Constructor & Destructor."

Similar presentations


Ads by Google