my question is:
Write a function that accepts an integer parameter and returns its integer
square root. The function should throw an exception if it is passed an
integer that is not a perfect square. Demonstrate the function with a
suitable driver program.
i am getting that : Error 1 error C3861: 'squareRoot': identifier not found Exception
the line that's in bold
#include <iostream>
#include "ArithmeticHeader.h"
using namespace std;
int main()
{
for (int c = 1;c <= 3; c++)
{
try
{
int number;
int sqrt;
cout << "Enter a number";
cin >> number;
[B]sqrt = squareRoot(number);[/B]
cout << "The integer square root is: "<< sqrt << endl;
}
catch (SqrtException exc)
{
int badArg = exc.getArgument();
cout << "Exception" << badArg
<< " does not have an integer square root. " << endl;
}
}
cout << endl << endl;
}
int squareRoot(int number)
{
int c = 0;
while (c * c < number)
c++;
if(c * c == number) return c;
throw SqrtException(number);
}
#ifndef ARITHMETICHEADER_H
#define ARITHMETICHEADER_H
#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
class SqrtException
{
int arg;
public:
SqrtException(int arg)
{
this->arg = arg;
}
int getArgument(){return arg;}
};
#endif /* ARITHMETICHEADER.h*/