K
karthikbalaguru
Hi,
I wonder how the 'm' value is 10 in the program below . It should be
7.
Further, it turns later to 11. Strange. How is it possible ? Why ?
Need clarification. Any ideas ?
using namespace std;
#include <iostream>
double &biggest (double &r, double &s)
{
if (r > s) return r;
else
return s;
}
int main ()
{
double k = 3;
double m = 7;
cout << "k: " << k << endl; // Displays 3
cout << "m: " << m << endl; // Displays 7
cout << endl;
biggest (k, m) = 10;
cout << "k: " << k << endl; // Displays 3
cout << "m: " << m << endl; // Displays 10 /* How is this
possible . m was actually 7. how it prints 10 */
cout << endl;
biggest (k, m) ++;
cout << "k: " << k << endl; // Displays 3
cout << "m: " << m << endl; // Displays 11 /* How is it 11
here */
cout << endl;
return 0;
}
Any ideas ?
Thx in advans,
Karthik Balaguru
I wonder how the 'm' value is 10 in the program below . It should be
7.
Further, it turns later to 11. Strange. How is it possible ? Why ?
Need clarification. Any ideas ?
using namespace std;
#include <iostream>
double &biggest (double &r, double &s)
{
if (r > s) return r;
else
return s;
}
int main ()
{
double k = 3;
double m = 7;
cout << "k: " << k << endl; // Displays 3
cout << "m: " << m << endl; // Displays 7
cout << endl;
biggest (k, m) = 10;
cout << "k: " << k << endl; // Displays 3
cout << "m: " << m << endl; // Displays 10 /* How is this
possible . m was actually 7. how it prints 10 */
cout << endl;
biggest (k, m) ++;
cout << "k: " << k << endl; // Displays 3
cout << "m: " << m << endl; // Displays 11 /* How is it 11
here */
cout << endl;
return 0;
}
Any ideas ?
Thx in advans,
Karthik Balaguru