Note that there are some explanatory texts on larger screens.

plurals
  1. PO"numrt": identifyer not found despite of defining that function
    text
    copied!<p>I'm writing a library of mathematical functions in C++. I made the sqrt function and it works well. I also tried to make a root function that counts n'th root of a number. I have 3 files - emath.cpp, emath.hpp, main.cpp (emath is name of my library).</p> <p>emath.cpp:</p> <pre><code>namespace emath { class emath { public: /* ... */ //Returns value of square root of a number. static double sqrt(double tur); //Rerurns value of a root of a number. static double numrt(int stopien, double tur); }; } </code></pre> <p>emath.hpp:</p> <pre><code>#ifndef EMATH_HPP #define EMATH_HPP using namespace std; namespace emath { class emath { public: /* ... */ int emath::derivative(double x) { return 0; } //**************************************************************** double emath::derivative(double number, int pow) { double result = 1; for (int i = 1; i &lt; pow; i++) { result *= number; } result *= pow; return result; } //************************************************************************ double emath::derivative(double number, int pow, double numbey) { return ((derivative(number, pow) + derivative(numbey))); } //************************************************************************ double emath::sqrt(double tur) //This function { int a; static int i = 0; for (; i * i &lt;= tur; i++) { } if (i * i == tur) { return i; } a = i; return sqrtl(a); } //************************************************************************ double emath::numrt(int stopien, double tur) //This function { int a; static int i = 0; for (; i * i &lt;= tur; i++) { } if (i * i == tur) { return i; } a = i; static int mul = 1; for (int p = 0; p &lt; stopien; p++) { mul *= i; } return numrtel(mul, i, a); } private: //**************************************************************** double emath::sqrtel(double tur, static int k = 0) //Implementation of Newton's Method { double a; //Creates a - our xn. if (k == 1000000) { return a; } a = a - ((a * a - tur) / derivative(a, 2, - tur)); //Proper implementation os Newton's Method ++k; //k is counter return sqrtel(a); } //*************************************************************** double emath::numrtel(int mul, int i, double tur, static int k = 0) { double a; //Creates a - our xn. if (k == 1000000) { return a; } a = a - ((mul - tur) / derivative(a, i, - tur)); //Proper implementation os Newton's Method ++k; //k is counter return numrtel(mul, i, a); } }; //end of class } //end of namespace #endif // EMATH_HPP </code></pre> <p>If my main.cpp is</p> <pre><code>#include &lt;iostream&gt; #include "emath.hpp" using namespace std; using namespace emath; int main() { double number; cin &gt;&gt; number; cout &lt;&lt; sqrt(number); } </code></pre> <p>it works very well, but if main.cpp is</p> <pre><code>#include &lt;iostream&gt; #include "emath.hpp" using namespace std; using namespace emath; int main() { double number; cin &gt;&gt; number; cout &lt;&lt; numrt(3, number); } </code></pre> <p>I get a compiler error: "numrt": identifyer not found. I'm using MS VS Studio 2012 Compiler with Qt Creator. Why is that?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload