No match for operator!
Hello, I am new to C++ but I program in Python. I am getting a really weird error saying that there is no match for an operator for cin.
here is my code:
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <iostream>
using namespace std;
int main()
{
int i;
cout << "Please enter an integer value: ";
cin << i;
cout << "you entered " << i;
}
|
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <iostream>
using namespace std;
int main()
{
int i;
cout << "Please enter an integer value: ";
cin>>i;
cout << "you entered " << i;
}
|
Line 10:
cin<<i;
is not correct. It has to be
cin>>i;
Last edited on
As CosminNTG said, the extraction operator follows the object cin.
Best of luck,
Robert
Does it matter if there is a space between cin<<i; or could I put cin << i; ?
Nope. You could do this, if you wanted too.
1 2 3 4 5 6 7 8 9 10 11
|
int main ()
{
std::cin >> i;
// Or even
std::cout <<
"I am connected to the insertion opertator.\n";
cin.ingore();
return 0;
}
|
Last edited on
Topic archived. No new replies allowed.