Is there a standard sign function (signum, sgn) in C/C++?

I want a function that returns -1 for negative numbers and +1 for positive numbers. http://en.wikipedia.org/wiki/Sign_function It’s easy enough to write my own, but it seems like something that ought to be in a standard library somewhere. Edit: Specifically, I was looking for a function working on floats.

Difference between and

The cstring header provides functions for dealing with C-style strings — null-terminated arrays of characters. This includes functions like strlen and strcpy. It’s the C++ version of the classic string.h header from C. The string header provides the std::string class and related functions and operators. The headers have similar names, but they’re not really related … Read more

How can I add reflection to a C++ application?

I’d like to be able to introspect a C++ class for its name, contents (i.e. members and their types) etc. I’m talking native C++ here, not managed C++, which has reflection. I realise C++ supplies some limited information using RTTI. Which additional libraries (or other techniques) could supply this information?

Function cannot be referenced as it is a deleted function

You can’t return an istream by value because it’s not copyable. Since it’s not copyable the copy constructor has been deleted (to enforce the non-copyability), and that’s the direct technical cause of the diagnostic. So, instead of … do In other news, … Instead of just turn off precompiled headers in the Visual Studio project … Read more

C++ Array of pointers: delete or delete []?

delete[] monsters; Is incorrect because monsters isn’t a pointer to a dynamically allocated array, it is an array of pointers. As a class member it will be destroyed automatically when the class instance is destroyed. Your other implementation is the correct one as the pointers in the array do point to dynamically allocated Monster objects. … Read more

How to automatically convert strongly typed enum into int?

Strongly typed enums aiming to solve multiple problems and not only scoping problem as you mentioned in your question: Provide type safety, thus eliminating implicit conversion to integer by integral promotion. Specify underlying types. Provide strong scoping. Thus, it is impossible to implicitly convert a strongly typed enum to integers, or even its underlying type … Read more

no debugging symbols found when using gdb

Some Linux distributions don’t use the gdb style debugging symbols. (IIRC they prefer dwarf2.) In general, gcc and gdb will be in sync as to what kind of debugging symbols they use, and forcing a particular style will just cause problems; unless you know that you need something else, use just -g.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)