-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvector_1.cpp
76 lines (59 loc) · 1.16 KB
/
vector_1.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <vector>
#include <string>
using namespace std;
/*
This practice is practcie looping through a vector
*/
class Member{
public:
//defualts
Member(): uname("undefined"), pass("undefined"){
return;
}
//mutators
void setUname(string username){
uname = username;
}
void setPass(string password){
pass = password;
}
void setItemListSize(int size){
vector<int> itemList(size);
}
//accessors
string getUname(){
return uname;
}
string getPass(){
return pass;
}
private:
string uname;
string pass;
};
int main(){
int memberNum = 10;
vector<Member> memberID(memberNum);
cout << "How many members (max 10): ";
cin >> memberNum;
//set username
string uname ="?";
string password = "0123";
for(int i = 0; i < memberNum; i++){
cout << "Member #" << i + 1 << " Name: ";
cin >> uname;
memberID.at(i).setUname(uname);
cout << "Set Password: ";
cin >> password;
memberID.at(i).setPass(password);
cout << endl;
}
for(int i = 0; i < memberNum; i++){
cout << memberID.at(i).getUname() << " ";
cout << endl;
}
cout << endl;
cout << memberID.at(1).getPass() << endl;
return 0;
}