cout prints "-0" instead of "0"
#include <iostream> using namespace std; int main() { double u = 0; double w = -u; cout << w << endl; return 0; } Why does this great piece of code outputs "-0" and not "0", as one would expect? ...
#include <iostream> using namespace std; int main() { double u = 0; double w = -u; cout << w << endl; return 0; } Why does this great piece of code outputs "-0" and not "0", as one would expect? ...
I have a small to medium project that is in C++/CLI. I really hate the syntax extensions of C++/CLI and I would prefer to work in C#. Is there a tool that does a decent job of translating one to the other? EDIT: When I said Managed c++ before I apparently meant c++/CLI ...
Does anyone have a good recommendation for an ORM (Object Relational Mapper) for C++? Our technology stack is: IDE/C-Compiler = Borland C++ Builder so ideally something that is known to compile with BCC. We use PostgreSQL as our database and developed our own database abstraction layer using common API to many driver type interface. S...
I am working on a large C++ project in Visual Studio 2008, and there are a lot of files with unnecessary #include's. Sometimes the #include's are just artifacts and everything will compile fine with them removed, and in other cases classes could be forward declared and the #include could be moved to the .cpp file. Are there any good to...
Hello. I'm trying to implement some drag and drop functionality for a material system being developed at my work. Part of this system includes a 'Material Library' which acts as a repository, divided into groups, of saved materials on the user's hard drive. As part of some UI polish, I was hoping to implement a 'highlight' type feature....
Possible Duplicate: The Definitive C++ Book Guide and List I'm looking to pick up a good C++ book. I have been programming for many years in managed languages and I will me making the jump to native code using C++. What books do you recommend to get me up to speed with all the intricacies of C++. Thanks. ...
Windows file system is case insensitive. How, given a file/folder name (e.g. "somefile"), I get the actual name of that file/folder (e.g. it should return "SomeFile" if Explorer displays it so)? Some ways I know, all of which seem quite backwards: Given the full path, search for each folder on the path (via FindFirstFile). This gives ...
I have a C++ program that when run, by default, displays the X in the upper right corner. Clicking X, minimizes the program. I've added code using the SHInitDialog function to change the X to OK, so that clicking OK exits the program. My question: Is there a better method that applies to the window, since SHInitDialog works best with Di...
If you have a statically allocated array, the Visual Studio debugger can easily display all of the array elements. However, if you have an array allocated dynamically and pointed to by a pointer, it will only display the first element of the array when you click the + to expand it. Is there an easy way to tell the debugger, show me thi...
In C/C++, what is an unsigned char used for? How is this different from a regular char? ...
In C++, what is the purpose of the scope resolution operator when used without a scope? For instance: ::foo(); ...
The Visual Studio compiler does not seem to warn on signed/unsigned assignments, only on comparisons. For example the code below will generate a warning on the if statement but not the initial assignments. Is there anyway to make it catch these? I'm already at W4 but thought (hoped) there may be another setting somewhere. Thanks, int ...
I am using URLDownloadToFile to retrieve a file from a website. Subsequent calls return the original file rather than an updated version. I assume it is retrieving a cached version. ...
No C++ love when it comes to the "hidden features of" line of questions? Figured I would throw it out there. What are some of the hidden features of C++? ...
Let's say I write a DLL in C++, and declare a global object of a class with a non-trivial destructor. Will the destructor be called when the DLL is unloaded? ...
In C#, if I want to deterministically clean up non-managed resources, I can use the "using" keyword. But for multiple dependent objects, this ends up nesting further and further: using (FileStream fs = new FileStream("c:\file.txt", FileMode.Open)) { using (BufferedStream bs = new BufferedStream(fs)) { using (StreamReade...
Is there a way to have a 64 bit enum in C++? Whilst refactoring some code I came across bunch of #defines which would be better as an enum, but being greater than 32 bit causes the compiler to error. For some reason I thought the following might work: enum MY_ENUM : unsigned __int64 { LARGE_VALUE = 0x1000000000000000, }; ...
What are some general tips to make sure I don't leak memory in C++ programs ? How do I figure out who should free memory that has been dynamically allocated ? ...
When my c++ app crashes I would like to generate a stacktrace. I already asked this but I guess I needed to clarify my needs. My app is being run by many different users and it also runs on Linux, Windows and Macintosh ( all versions are compiled using gcc ). I would like my program to be able to generate a stack trace when it crashes...
I am looking for an open-source project involving c++ GUI(s) working with a database. I have not done it before, and am looking for a way to get my feet wet. Which can I work on? ...