[KOSSA] C++ Programming - 18th Study - STL #4
-
Upload
seok-joon-yun -
Category
Software
-
view
52 -
download
1
Transcript of [KOSSA] C++ Programming - 18th Study - STL #4
3
4
typedef std::basic_string<char> string
typedef std::basic_string<wchar_t> wstring
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);
6
std::string s1("Hello");s1 += ' ';s1 += "C++";s1.push_back(' ');s1.append("world");
std::cout << s1 << std::endl;
7
std::string s1("Hello!");const char *sz;
sz = s1.c_str();
std::cout << "sz : " << sz << std::endl;
9
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();
}}
12
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();
}}
15