Question

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?

Was it helpful?

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.

OTHER TIPS

How about define it yourself or simply use a multiply operator?

And for your information, C++ does not define a square function in the standard definition.

Stuck on same example from same book. I removed square and used * . Works fine. Example;

cout<< i<<'  \ t'<< i* i<<" \n";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top