Mar 16, 2010 at 6:46am UTC
I've just begun learning C++
got some problems with error finding...
I know there are some errors in these program segments
but not sure exactly what they are
nor know how to explain
please help me out ...
: )
ps. For a particular program segment,
there may be no errors present in the segment.
a)
template < class A >
int sum( int num1, int num2, int num3 )
{
return num1+ num2+ num3;
}
b)
void printResults( int x, int y )
{
cout << "The sum is " << x + y << '\n';
return x + y;
}
c)
template <A>
A product(A num1, A num2, A num3 )
{
return num1 * num2 * num3;
}
d)
double cube( int );
int cube( int );
Mar 16, 2010 at 9:19am UTC
I'm not sure about d)
I believe you cannot overload a function by its return value, only by its paramter list.
Mar 16, 2010 at 10:51am UTC
I've learnt a little about C last term
and this term we're going on to C++
I didn't catch up with progress last term
so kind of have a big problem now
simply just using templates gives me a big headache~
anyway,
thank you all sooooooooo much ^ ^