File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -180,4 +180,11 @@ This example shows how to use two functions with same name. The only difference
180180 * ` inline `
181181 * Use two different functions with same name
182182
183-
183+ #### Vector
184+ Some examples to show how to use vectors
185+ * Files
186+ * ` vectorArg.cpp ` - Show how to pass vector as an argument
187+ * Subjects
188+ * Vector as an arguments
189+ * ` vector::push_back() `
190+ * ` vector::size() `
Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ #include < vector>
3+
4+ //
5+ // Example passing a string vector as a parameter
6+ //
7+
8+ using namespace std ;
9+
10+ int incVec (vector<string> & v)
11+ {
12+
13+ v.push_back (" item 0" );
14+ v.push_back (" item 1" );
15+
16+ return 0 ;
17+ }
18+
19+ int main (int argc, char * argv[])
20+ {
21+ vector<string> names;
22+
23+ int x = incVec (names);
24+ int s = names.size ();
25+
26+ cout << " Size of vector: " << s << " \n " ;
27+
28+ for (int i = 0 ; i < s; i++)
29+ cout << names[i] << " \n " ;
30+
31+ }
You can’t perform that action at this time.
0 commit comments