c++ - Error code C2451 cannot run basic program -


i trying create program asks question, , gives 1 of 2 answer based on response (response = yes or no). here code :-

 #include <iostream>   #include <string>   using namespace std;   int main()  {     string answer, yes;      cout << "is lucy top lass ? enter yes or no" << endl;     cin >> answer;     if (answer == yes)      {         cout << "correctomundo" << endl;     }     else     {         cout << " blasphemy ! " << endl;     }     return 0; } 

i getting error c2451. can please explain how must edit code in order work way want ?

i using header files iostream, , string. not show reason contained within triangular brackets.

thankyou.

if (answer = yes)

a) it's assignment (=) not equality check (==)

b) yes has no value - meant string answer, yes = "yes"; or use "yes" directly instead of having variable yes.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -