String vector acces by index

I am trying to implement a DFA.
I have this method that has a vector of strings as parameteres

start(lines.at[i]); this line of code gives me an error because here I am trying to access an index.
How should I do it?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 void AFD::start(vector <string> lines){
	if (std::find(lines.begin(), lines.end(), "a") != lines.end()) {
		dfa = 1;
	}
	else if (std::find(lines.begin(), lines.end(), "b") != lines.end()) {
		dfa = 3;
	}
	// -1 is used to check for any invalid symbol 
	else {
		dfa = -1;
	}
}
The problem is when I try to access it in another method
int AFD::isAccepted(vector <string> lines){
	int i;
	// store length of string 
	int len = lines.size();
	//int index = lines.at(i);
	for (size_t i = 0; i < lines.size(); ++i) {
		if (dfa == 0)
			start(lines.at[i]);
}
}
Last edited on
lines[i] or lines.at(i)
Tried it. Still doesn't take work
lines.at[i] is ref to string, you pass this to start() taking a vector of string?
yes, you are right, now I realise. but how can I give lines[i] as a parameter?
Topic archived. No new replies allowed.