알고리즘/c, c++
C++ - vector<string> 복사 & cout 으로 출력
yulme
2020. 10. 16. 02:51
SMALL
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<string> s1{ "hello","hi" };
vector<string> s2 = s1;
cout << *s2.begin();
}
또는
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<string> s1{ "hello","hi" };
vector<string> s2 = s1;
vector<string>::iterator iter;
iter = s2.begin();
cout << *iter;
}
또는
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<string> s1{ "hello","hi" };
vector<string> s2 = s1;
cout << s2.at(0);
}
=> hello 가 출력됨
반응형