#include <iostream>
usingnamespace std;
//Function prototype
int function(int);
int main()
{
int number;
cout << "Enter an integer value and I will display\n";
cout << "the value: ";
cin >> number;
cout << "The function of " << number << "is";
cout << function(number) << endl;
system("pause");
return 0;
}
int func(int base, int power)
{ base=3;
if(power == 2)
return pow(base, power);
return pow(base, power) + function(base, power + 1);
}
#include <iostream>
usingnamespace std;
//Function prototype
int func(int);
int main()
{
int number;
cout << "Enter an integer value and I will display\n";
cout << "the value: ";
cin >> number;
cout << "The function of " << number << "is";
cout << func(number) << endl;
system("pause");
return 0;
}
int func(int base, int power)
{ base=3;
if(power <= 2)
return pow(base, power);
elseif (power==1)
return 9;
elsereturn pow(base, power) + func(base, power + 1);
}
#include <iostream>
#include <iomanip>
#include <cmath>
usingnamespace std;
//Function prototype
int func(int);
int main()
{
int number;
cout << "Enter an integer value and I will display\n";
cout << "the value: ";
cin >> number;
cout << "The function of " << number << "is";
cout << func(number) << endl;
system("pause");
return 0;
}
int func(int base, int power)
{ base=3;
if(power <= 2)
return pow(base, power);
elseif (power==3)
return 27;
elsereturn pow(base, power) + func(base, power + 1);
}
c:\users\me\qqq.cpp(27): error C2556: 'double func(double)' : overloaded function differs only by return type from 'int func(double)'
c:\users\me\qqq.cpp(12) : see declaration of 'func'
c:\users\me\qqq.cpp(27): error C2371: 'func' : redefinition; different basic types
c:\users\me\qqq.cpp(12) : see declaration of 'func'
@Jaybob66 Yep, you're 100% right. I got the same errors running it, not a LNK1561. And In my post which is 3 posts above this one, I provided the solution.
@TarikNeaj
Yes, your solution is the solution to his code issues,
But the error he reports makes me think that he has other problems, like a project setting wrong or something. OP makes no point about overloading/redefinition errors (c++ problems)
Only the linker one.