Does anyone know how to use this code??

I got an assignment to make an FSM.
From the input string I have to update each states.!!!
In the given header file, I see this code!!
namespace cppfsm {
	/*            constants             */
	// character classes:
	string s_alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        const set<char> alpha(s_alpha.c_str(),s_alpha.c_str()+s_alpha.length());

There are more code like this but I won't post everything because it is too long!!
Can anyone explain what this code is??
Looks like two global constant variables (lol) put in the cppfsm namespace.
One variable is an std::string and is initialized to the alphabet.
The other variable is an std::set container, constructed to contain all the letters in the s_alpha string.

Sets have a special rule: they don't contain more than one element of a given value (say you add another 'A' character to alpha, you'd still only have a single 'A' in it because nothing gets added). They also appear to sort themselves automatically, because they're usually implemented via trees.
Thanks for the answer!!
So each alphabet in s_alpha assigned into set alpha like 'A', 'B', ... 'z' ???

Here's an example program that displays the contents.
I have one more question!!
If I get input string like this!! "I have to do homework," and I want to check if 't' is in this string, do I still have to use loop and iterator?? or is there another way to check this??
I know that in python language, if I do 't' in "I have to do homework," it returns boolean!! is there a way to do same thing in c++??
Last edited on
std::string has an overloaded find() member function.
Last edited on
Thanks a lot!!
Topic archived. No new replies allowed.