floating point issue
Hi, I have a floating value as 0.1 entering from UI. But, while converting that string to float i am getting as 0.10...01. The problem is the appending of non zero digit. How do i tackle with this problem. Thanks, iSight ...
Hi, I have a floating value as 0.1 entering from UI. But, while converting that string to float i am getting as 0.10...01. The problem is the appending of non zero digit. How do i tackle with this problem. Thanks, iSight ...
Hi , Should we delete before or after erase. My understanding is both are OK. Is it correct? In addition, is there any case we won't want to delete the element while erasing it? I believe there must be , otherwise, the erase will be happy to take the responsibility. std::vector<foo*> bar; ... for (vector<foo*>::iterator itr = bar.be...
Hello Stack Overflow! This is my first question here so be kind :-) I'm trying to make a recursive call here, but I get the following compiler error: In file included from hw2.cpp:11: number.h: In member function ‘std::string Number::get_bin()’: number.h:60: error: no matching function for call to ‘Number::get_bin(int&)’ number.h:27: no...
I need to be able to unzip some AES (WinZip) encrypted zip files from within some C/C++ code on Windows. Has anybody got a way to do this? I'm hoping for either some appropriate code or a DLL I can use (with an example usage). So far my searches have proved fruitless. The commonly prescribed InfoZip libraries do not support AES encrypt...
I'm using Boost.Python to expose JRA's BWRepLib so I can try to do some data mining on sc:bw replays in python and I've run into a small problem with the values being returned from the C++ methods. When running any old simple program such as the tutorial I get the expected value returned to python (a "hello, world" string that prints out...
What should go into a class declaration in C++? For example, I have the following in a header file: class BoardState { public: BoardState(); bool HasWon() const; bool HasMoves() const; bool MakeMove(const int column); bool UndoMove(const int column); const Chip (&grid() const)[kGridHeight][kGridWidth] { return grid_; } ...
So I had to write a program for a computer project for high school and I thought of doing a sudoko solver. The 'solve' algorithm is implemented like this:- For any points where only one element 'fits' looking at rows, columns, 3x3 set, put that number in. Do this repeatedly till it can't be done anymore. This is seen in the 'singleLeft...
My question is w.r.t the following thread : http://stackoverflow.com/questions/2009924/specialize-a-member-template-without-specializing-its-parent I'm absolutely fine with the standard saying that it is illegal to do so. But i want to understand why is it illegal to do so? What would be impact had it been allowed? ...
I am trying to use Google's Sketchup C++ SDK (latest version) to export a 3D model to a Sketchup file. One of the problems I am facing is that the header files refer to an "sapi" folder which does not exist in the source tree. I need to figure out how I can get a reference to the ISketchUpApplication interface. Can someone provide me w...
Hi, I recently interviewed with a company and they asked me to write an algorithm that finds the subsequence with largest sum of elements in an array. The elements in the array can be negative. Is there a O(n) solution for it? Any good solutions are very much appreciated. ...
Hi All Do you know whether there is a good FREE C++ Source code editor other than Visual Studio ? The only feataure I might really need are class browsing (jumping from a method call to a class declaration/dfinition) and (whenever is possible) code completion. I really need only writing source code + those 2 features and nothing else o...
Hello! I started using Nvidia Cg shaders recently and everything looks and works fine if I'm doing it on the Nvidia GPU (GTS250 in my case). I tried launching the same (my own test application) on ATI HD4650 and saw no output. Right after that I started experimenting with test examples (provided with Nvidia Cg 3.0) and 6/7 work, but th...
I am completely confused as to the proper way to layout a C++ project. I had all my classes in separate .cpp files, with their definitions in .h files. I then had one "header.h" which contained all the class headers, external dependencies and a few other things. But I wasn't able to use class names in the header files, where I needed to...
Hello, I've been programming badly for quite a while and I only really just realised. I have previously created many functions that return character strings as char arrays (or at least pointers to them). The other day someone pointed out that when my functions return the char arrays pointed to by my functions have gone out of scope and...
Do you have to declare methods replacing a pure virtual function in a base class? If so, why? Because the base class has declared the methods as pure virtual, and therefore MUST exist in derived class, then is should not be necessary to redeclare them in the derived class before you can implement them outside of the class definition. Wou...
Hello, I have two classes (ClassA and ClassB) who both have two methods (compare and converge). These methods work exactly the same way, but these classes are not related polymorphically (for good reason). I would like to define a function template that both of these classes can explicitly instantiate as a member but I'm getting error...
I need to check whether my CString object in MFC ends with a specific string. I know that boost::algorithm has many functions meant for string manipulation and that in the header boost/algorithm/string/predicate.hpp could it be used for that purpose. I usually use this library with std::string. Do you know a convenient way to use this ...
Im using mfc to draw a custom menu except it has a nasty looking border around it. How do i get rid of the border or draw over it? ...
This problem is pretty common: an object should notify all its subscribers when some event occurs. In C++ we may use boost::signals or something else. But how to do this in Go language? It would be nice to see some working code example where a couple of objects are subscribed to a publisher and process notifications. Thanks ...
How do I get the amount of free virtual memory on Mac OSX? I'm speaking of total free virtual memory (or: free addresses) and also the biggest allocatable continous block of memory available for the current process. (Like e.g. on Windows returned by GlobalMemoryStatus (free mem) or querieable with a combination of GetSystemInfo / Virt...