[kossa] c++ programming - 18th study - stl #4

15

Upload: seok-joon-yun

Post on 28-Jul-2015

51 views

Category:

Software


1 download

TRANSCRIPT

Page 1: [KOSSA] C++ Programming - 18th Study - STL #4
Page 2: [KOSSA] C++ Programming - 18th Study - STL #4
Page 3: [KOSSA] C++ Programming - 18th Study - STL #4

3

Page 4: [KOSSA] C++ Programming - 18th Study - STL #4

4

typedef std::basic_string<char> string

typedef std::basic_string<wchar_t> wstring

Page 5: [KOSSA] C++ Programming - 18th Study - STL #4

5

#include <iostream>#include <string>

std::string str("Hello!");const char* p1 = "Hello!";const char* p2 = p1 + 6;

std::string s1;std::string s2("Hello!");std::string s3("Hello!", 2);std::string s4(5, 'H');std::string s5(str.begin(), str.end());std::string s6(p1, p2);

Page 6: [KOSSA] C++ Programming - 18th Study - STL #4

6

std::string s1("Hello");s1 += ' ';s1 += "C++";s1.push_back(' ');s1.append("world");

std::cout << s1 << std::endl;

Page 7: [KOSSA] C++ Programming - 18th Study - STL #4

7

std::string s1("Hello!");const char *sz;

sz = s1.c_str();

std::cout << "sz : " << sz << std::endl;

Page 8: [KOSSA] C++ Programming - 18th Study - STL #4
Page 9: [KOSSA] C++ Programming - 18th Study - STL #4

9

Page 10: [KOSSA] C++ Programming - 18th Study - STL #4

10

#include <iostream>#include <stack>

using namespace std;

void main(){

stack<int> st;

st.push(1);st.push(2);st.push(3);

int count = st.size();for (int i = 0; i < count; i++){

cout << st.top() << endl;st.pop();

}}

Page 11: [KOSSA] C++ Programming - 18th Study - STL #4
Page 12: [KOSSA] C++ Programming - 18th Study - STL #4

12

Page 13: [KOSSA] C++ Programming - 18th Study - STL #4

13

#include <iostream>#include <queue>

using namespace std;

void main(){

queue<int> qu;

qu.push(1);qu.push(2);qu.push(3);

int count = qu.size();for (int i = 0; i < count; i++){

cout << qu.front() << endl;qu.pop();

}}

Page 14: [KOSSA] C++ Programming - 18th Study - STL #4
Page 15: [KOSSA] C++ Programming - 18th Study - STL #4

15