This commit is contained in:
zhuyijun 2021-09-16 23:10:54 +08:00
parent 48971c53ac
commit de2f77b2b8
2 changed files with 37 additions and 1 deletions

View File

@ -78,4 +78,5 @@ add_executable(newexcp exception/newexcp.cpp)
add_executable(use_sales exception/use_sales.cpp)
add_executable(rtti1 exception/rtti1.cpp)
add_executable(rtti2 exception/rtti2.cpp)
add_executable(constcast exception/constcast.cpp)
add_executable(constcast exception/constcast.cpp)
add_executable(str1 string/str1.cpp)

35
base/string/str1.cpp Normal file
View File

@ -0,0 +1,35 @@
//
// Created by nicemoe on 2021/9/16.
//
#include <iostream>
#include<string>
using namespace std;
int main() {
string one("Lottery Winner!");
cout << one << endl;
string two(20, '$');
cout << two << endl;
string three(one);
cout << three << endl;
one += " Oops!";
cout << one << endl;
two = "Sorry!That was ";
three[0] = 'P';
string four;
four = two + three;
cout << four << endl;
char alls[] = "All's well that ends well";
string five(alls, 20);
cout << five << ", ";
string six(alls + 6, alls + 10);
cout << six << ", ";
string seven(&five[6], &five[10]);
cout << seven << "...\n";
string eight(four, 7, 16);
cout << eight << " in motion!" << endl;
return 0;
}