-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitializationWays.cpp
More file actions
51 lines (38 loc) · 1.17 KB
/
InitializationWays.cpp
File metadata and controls
51 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* \file InitializationWays.cpp
* \brief
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//--------------------------------------------------------------------------------------------------
int main(int, char **)
{
// various constructor of string class
// initialization by raw string
std::string str1("first string");
// initialization by another string
std::string str2(str1);
// initialization by character with number of occurence
std::string str3(5, '#');
// initialization by part of another string
// from 6th index (second parameter)
// 6 characters (third parameter)
std::string str4(str1, 6, 6);
// initialization by part of another string : iteartor version
std::string str5(str2.begin(), str2.begin() + 5);
std::cout << str1 << std::endl;
std::cout << str2 << std::endl;
std::cout << str3 << std::endl;
std::cout << str4 << std::endl;
std::cout << str5 << std::endl;
return EXIT_SUCCESS;
}
//--------------------------------------------------------------------------------------------------
#if OUTPUT
first string
first string
#####
string
first
#endif