Search code examples
c++functioncmath

unable to use square() function c++


I'm new to C++ and I'm using the book "Programming Principles and Practice Using C++" by Bjarne Stroustrup (I will use this book in a future school course). The code samples in this book make use of std_lib_facilities.h. At some point the book calls the function square(), but when I do that I get the following error:

error C3861: 'square': identifier not found

On the other hand, I am able to use the sqrt() function... I do include the std_lib_facilities.h, and that one includes the cmath, so I think thats is not the problem?

What should I do to use the square() function?


Solution

  • There is no square function declared or defined in that header (proof: Ctrl+f).

    There isn't one in the standard library, either.

    From what I can tell from the book, it mentions this function as an example of a function that you can define yourself, and shows you how to do that. It's not expected to be readily-available.