// Hangman function
void PlayHangman(string str1)
char letter=' ';
bool match= false;
for(string::size_type i=0; i < str1.size(); i++)
cout << "User word is " << secret << endl;
cout << "Enter a letter " << endl;
cin >> letter;
for(string::size_type i=0; i < str1.size();i++)
The problem I think it the last cluster of code. This is supposed to replace the secret word at i with the letter but it is not working. Can someone also tell me what exactly :: is in the str1::size_type I used it from an example my teacher gave without knowing exactly why.
Anyways that last cluster of code is giving me a hard time.
D*MMIT! I got it. Sorry but still can someone help me understand what the :: thing is all about I wrote about above also in the function heading my teacher used const string original what is this about also?
string::size_type means that defined type size_type belongs to class string.
As for your function it is better to declare the parameter as const reference to sttring because 1) it is not changed in the function body 2) there is no need to call a constructor to create the parameter that is a local variable of the function.
OK I did that it that was a good idea. I know this is is a more of the same but :: is the scope resolution operator right ? In a sense when I have string:: size type_ i=0; I'm just defining i to be a string? But Is this :: still the scope resolution operator? Or is it something different in this case .... Sorry just trying to get it all straightened out.
I read it is just confusing so when you use string::size_type the :: in this case isn't the scope resolution operator?
And you didn't answer about my question regarding
string secret( str1.size(), '*' );
All this is declaring a variable right? So how come you don't have to initailize it to somthing like this .... string secret =( str1.size(), '*' ); Thats what I want to know.
Sorry dude I try :) I'm looking at my book right now!