sjbrown8@eng.usf.edu wrote:
I have the piece of code below, and when i try compiling with the line
g++ 753075304.cpp
I get the following error message:
753075304.cpp: In function 'int main()':
753075304.cpp:29: error: 'plus' was not declared in this scope
(...)
#include <iostream>
using namespace std;
#include <cmath>
double quad(double, double, double);
double plus(double, double, double);
double neg(double, double, double);
int main()
{
double xpos;
double a;
double b;
double c;
double square;
double xneg;
cout << "This program will compute a quadratic equation\n";
cout << "Please enter a number: \n";
cin >> a;
cout << "Please enter another number: \n";
cin >> b;
cout << "Please enter a final number: \n";
cin >> c;
square = quad(a,b,c);
xneg = neg(a,b,square);
xpos = plus(a,b,square);
cout << "The positive function is: " << xpos << "\n";
cout << "The negative function is: " << xneg << "\n";
return 0;
}
(...)
I tried to compile it with GCC 3.4.2, adn it also failed.
The problem lies in a existing template version of plus in std
namespace. I think it is a GCC bug, because AFAIK the compiler *should*
prefer non-template functions, but anyhiw, there is a workaround: