Question:
c++: " no match for 'operator>>' "?
?
2011-09-22 22:05:15 UTC
First off, sorry- I'm a noob.

I'm getting these error messages:
functions.cxx:63: error: `end1' undeclared (first use this function)
functions.cxx:67: error: no match for 'operator>>' in 'std::cout >> "Please type a, ecc and theta for testing orbit_dist: "'
(repeatedly, I just listed the first instance of each error)

And my main() function is:
int main()
{
//declare variables
double ma, ecc, period, t, a, theta, wx, w0, w1, z;
int p0, p1;

//dialog
cout << "Please type ma and ecc for testing kepler_solution: ";
cin >> ma >> ecc;
cout << "kepler_solution is " << kepler_solution(ma, ecc) << end1;
cout << "Please type ecc, period and t for testing orbit_angle: ";
cin >> ecc >> period >> t;
cout << "orbit_angle is " << orbit_angle(ecc, period, t) << end1;
cout >> "Please type a, ecc and theta for testing orbit_dist: ";
cin << a << ecc << theta;
cout >> "orbit_dist is " >> orbit_dist(a, ecc, theta) >> end1;
cout >> "Please type wx, w0, w1, p0 and p1 for testing pixel: ";
cin << wx << w0 << w1 << p0 << p1;
cout >> "pixel is " >> pixel(wx, w0, w1, p0, p1) >> end1;
cout >> "Please type z for testing sr: ";
cin << z;
cout >> "the square root of z is approximately " >> sr(z) >> end1;
cout >> "Thank you, Mr. Kepler." >> end1;

//finish
return EXIT_SUCCESS;
}

and I included and .

What am I doing wrong? :'(
Four answers:
Wertle Woo
2011-09-22 22:08:13 UTC
1. You're typing end1 (END-ONE) instead of endl (END L).



2. I don't see the beginning of your code, but if you included iostream and didn't specify the namespaces, you'll need to add "using std::cout;" and "using std::cin;" (without quotes) to the top, or "using namespace std;" instead. Or fully qualify your calls to cout and cin by putting "std::" (without quotes) in front of every single use of them.



3. Do you have something against main returning 0 like it's supposed to instead of pressing an extra 10 keys to type the name of a constant to represent 0?



EDIT: The redirection operator in your cout and cin statements, starting about halfway down, start facing the wrong way (>> and <<);
Erika
2017-02-23 13:21:51 UTC
originally you're utilising a string type for the variable first on an identical time as you need to use an int - in spite of the reality that in case you p.c. to apply a char form like this char first; cin >> first; if (first=='a million') cout << "n ok, permit's !N"; else cout << "to start, please press one. ";
Pat
2011-09-22 22:08:59 UTC
end1 should be endl with a lower-case L, not a 1.
modulo_function
2011-09-22 23:03:08 UTC
I'm surprized that nobody solved your original question.

You have >> when you meant <<.

You're printing that prompt string. Compare with all your other uses to see.



It's



cin>> variable; // get a value from keyboard

cout<< variable; // send a variable to output.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...