C++ Finding largest Number

hk3008

Distinguished
Jan 29, 2012
43
0
18,580
ok so I am way confused I am debugging this one and it tells me

1>------ Build started: Project: Double High output, Configuration: Debug Win32 ------
1>Build started 2/20/2012 1:27:46 AM.
1>InitializeBuildStatus:
1> Touching "Debug\Double High output.unsuccessfulbuild".
1>ClCompile:
1> Output Double High.cpp
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(4): error C2447: '{' : missing function header (old-style formal list?)
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.26
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

and my code is


#include <iostream>
#include <cmath>
using namespace std;
{
int main()
{
//Enter Variables
cout << "Enter Variable a ";
cin >> a;
cout << "Enter Variable b";
cin >> b;
cout >> "Enter Variable c";
cin >> c;
}
{double num(double a, double b, double c)

if (a > b && a > c);
return a;
if (b > a && b > c);
return b;
return c;
}
}
what am I missing it seems simple and I think I have my algorithm right but it hates me :/

 
Solution
You seem to have a lot of braces there. The outermost braces are neither for a namespace nor a class, so I'm not sure why they are there. You also don't have an opening brace for the function num(), although there's a brace right before it on the same line, which shouldn't be there. Here is a better formatted version with the braces in the right spots:

Code:
#include <iostream>
#include <cmath>
using namespace std;

double num(double a, double b, double c)
{
    if (a > b && a > c);
        return a;
    if (b > a && b > c);
        return b;
    return c;
}

int main()
{
    //Enter Variables
    cout << "Enter Variable a ";
    cin >> a;
    cout << "Enter Variable b";
    cin >> b;
    cout >> "Enter Variable c";
    cin >> c;
}
...

hk3008

Distinguished
Jan 29, 2012
43
0
18,580
and I guess I shoudl include the funtion of it is supposed to be a function that accepts three doubles as parameters and returns the largest am I even on the right track?
 

randomizer

Distinguished
You seem to have a lot of braces there. The outermost braces are neither for a namespace nor a class, so I'm not sure why they are there. You also don't have an opening brace for the function num(), although there's a brace right before it on the same line, which shouldn't be there. Here is a better formatted version with the braces in the right spots:

Code:
#include <iostream>
#include <cmath>
using namespace std;

double num(double a, double b, double c)
{
    if (a > b && a > c);
        return a;
    if (b > a && b > c);
        return b;
    return c;
}

int main()
{
    //Enter Variables
    cout << "Enter Variable a ";
    cin >> a;
    cout << "Enter Variable b";
    cin >> b;
    cout >> "Enter Variable c";
    cin >> c;
}

Also, note that your num() function is never used. This program will simply get input for 3 variables and then exit.

I am assuming this is from a textbook, but try to avoid using variable names that have no meaning. It might be fine for a 15 line application, but when you get to 1500 lines you'll get lost if all you have are a's, b's and c's :) Oh, and comments are bad. Bad bad bad!
 
Solution

hk3008

Distinguished
Jan 29, 2012
43
0
18,580
lol thankyou very much my professor was trying to get us to comment more I think I cant remember lol anyways I will highlite the changes and look at what I need to start doing thank you very much it has been a challanging learning process

p.s. parts are from a text book and parts online lol I have been comparing peoples programs and taking what Ithink works and trying to recreate it to my liking lol even though I am not shure whats to my liking yet seeings how it doesnt allways work but experience is a learning process :)
 

hk3008

Distinguished
Jan 29, 2012
43
0
18,580
as well I tried to debug it with the changes :/ no luck

this is what it said


1>------ Build started: Project: Double High output, Configuration: Debug Win32 ------
1>Build started 2/20/2012 2:41:24 AM.
1>InitializeBuildStatus:
1> Touching "Debug\Double High output.unsuccessfulbuild".
1>ClCompile:
1> Output Double High.cpp
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(8): warning C4390: ';' : empty controlled statement found; is this the intent?
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(10): warning C4390: ';' : empty controlled statement found; is this the intent?
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(18): error C2065: 'a' : undeclared identifier
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(20): error C2065: 'b' : undeclared identifier
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Ty &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1128) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Ty &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1128) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Ty &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1128) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Ty &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1128) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1118) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1118) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1118) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1118) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,unsigned char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1111) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,unsigned char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1111) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,unsigned char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1111) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,unsigned char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1111) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,signed char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1104) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,signed char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1104) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,signed char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1104) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,signed char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1104) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,signed char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1097) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,signed char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1097) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,signed char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1097) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &,signed char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1097) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &,_Elem &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1090) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &,_Elem &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1090) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &,_Elem &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1090) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &,_Elem &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1090) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1082) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1082) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1082) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1082) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1074) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1074) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1074) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,unsigned char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1074) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,unsigned char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1067) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,unsigned char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1067) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,unsigned char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1067) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,unsigned char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1067) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,signed char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1060) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,signed char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1060) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,signed char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1060) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,signed char &)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1060) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,signed char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1053) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,signed char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1053) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,signed char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1053) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<char,_Traits> &std::eek:perator >>(std::basic_istream<char,_Traits> &&,signed char *)' : could not deduce template argument for 'std::basic_istream<char,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1053) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Elem &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1028) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Elem &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1028) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Elem &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1028) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Elem &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(1028) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(987) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(987) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(987) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2784: 'std::basic_istream<_Elem,_Traits> &std::eek:perator >>(std::basic_istream<_Elem,_Traits> &&,_Elem *)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::eek:stream'
1> c:\program files\microsoft visual studio 10.0\vc\include\istream(987) : see declaration of 'std::eek:perator >>'
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(21): error C2676: binary '>>' : 'std::eek:stream' does not define this operator or a conversion to a type acceptable to the predefined operator
1>c:\users\hk3008\documents\visual studio 2010\projects\double high output\double high output\output double high.cpp(22): error C2065: 'c' : undeclared identifier
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.26
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 

randomizer

Distinguished

Of course he was, that's a professor thing. University professors have an obsession with commenting code all over the place but he probably can't give you a very good reason why he wants you to do it. Here are a few reasons why you shouldn't:

1. Comments are a sign that your code can't be understood and needs explanation. Solution: write code that makes sense. In your example the comment doesn't even provide any extra information. It's obvious that the code requires user input, so there's no need to add a comment saying so.
2. Comments try to abstract the functionality of the code into a higher level explanation. Details are left out, and the comment might be misleading.
3. Comments can be flat out wrong. I have deleted comments from unit tests that described the exact opposite of what the code did.
4. Comments don't often get updated when the code gets updated. This means that even though the comment might have made sense to begin with, it becomes less accurate over time. See the previous two points.

When is a comment useful? When you are writing code to handle an unusual situation where the code might be clear and readable, but the rationale for the code isn't. Eg. You are trying to request data from a web server and place the request in a loop to be performed multiple times, when you haven't done it for any other requests to other servers. The server might be really crappy and hard to establish a connection with, but such a one-off situation might not be obvious to another developer. Therefore a comment that describes why the loop is needed helps prevent someone deleting what they think is useless code. The comment still shouldn't describe how it works.

Oops, wall of text :)
 

hk3008

Distinguished
Jan 29, 2012
43
0
18,580
wow didnt know it was that long sorry am I not defining the variables right or am I not asking the user for input correctly?
again Iam in a new project > new .cpp file do i need any other details to make it work?
 

randomizer

Distinguished
Ah, of course, you never declared those variables in your main() function. You are trying to assign user input to a, b and c but the compiler doesn't know what those variables are (or even if they are variables). I'm not sure about the other errors. I haven't done C++ for years (and never did much of it), so perhaps my syntax is wrong somewhere. You are using visual studio, so it should highlight the problem areas for you.