Switch problem in C++

Hello. I wrote this program.


#include <iostream>
#include <stdio.h>
#include <string>
using std :: cout;
using std :: endl;
using namespace std;


int main()
{
int Answer;
cout << "How old are you?" << endl;
cin << Answer; // [i]The error line 13[/i].
switch (Answer)
{
case 21:
cout << "congratulations! you are an adult now";
break;
case 20:
cout << "you're approved\n";
cout << "for 20 credit cards";
break;
case 19:
cout << "still officially a teenager";
case 18:
cout << "Now you can watch online porn without any guardiance";
break;
default:
cout << "not recognised./n";
cout << " what are you talking about?";
}
cout << "\nPress ENTER to continue" << endl;
getchar();
return 0;
}


And I get this error message for line 13.

|13|error: no match for 'operator<<' in 'std::cin << Answer'|

I think I need to include something else on top of the program which meant to be library. I also tried to use 'using std::cin' but it didn't work. Does this error message means something else?
cout uses <<
cin uses >>

Also, you do not need to declare:
1
2
using std::cout;
using std::endl;

since you have
using namespace std;
Topic archived. No new replies allowed.