[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
function call misinterpreted as a variable
From: |
sjbrown8 |
Subject: |
function call misinterpreted as a variable |
Date: |
Wed, 28 Sep 2005 02:02:16 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1 |
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
I've gone over the code several times line by lin, and my eyes are
starting to bleed. It looks totally fine to me, and I'm actually
wondering whether I found a compiler bug, but more likely some weird
feature, or I'm just totally missing something. And before anyone asks,
yes it is homework, but I am trying to grade it, not do it. my version
of GCC (as reported by its man page) is 4.0.1 2005-07-11 and I am
running debian testing, kernel version 2.6.8-1-386 #1
#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;
}
double quad(double n1, double n2, double n3)
{
double y;
double z;
double w;
double root;
y = 4*n1*n3;
z = n2 * n2;
w = z-y;
root = sqrt(w);
return root;
}
double plus( double n1, double n2, double n3)
{
double x;
x= (-1 * n2 + n3)/(2*n1);
return x;
}
double neg(double n1, double n2, double n3)
{
double x;
x= (-1 * n2 - n3)/(2*n1);
return x;
}