Maximum Width of a Printed Double in C++
I was wondering, how long in number of characters would the longest a double printed using fprintf be? My guess is wrong. Thanks in advance. ...
I was wondering, how long in number of characters would the longest a double printed using fprintf be? My guess is wrong. Thanks in advance. ...
Hi, I have a simple question hopefully - how does one free memory which was allocated in the try block when the exception occurs? Consider the following code: try { char *heap = new char [50]; //let exception occur here delete[] heap; } catch (...) { cout << "Error, leaving function now"; //delete[] heap; doesn't wo...
auto_ptr on wikipedia said that "an auto_ptr containing an STL container may be used to prevent further modification of the container.". It used the following example: auto_ptr<vector<ContainedType> > open_vec(new vector<ContainedType>); open_vec->push_back(5); open_vec->push_back(3); // Transfers control, but now the vector cannot be...
Explicitly setting dependency in VS2010 between unmanaged C++ project and C# project is honored in VS2010, but dependency is ignored in MSBuild 4.0. It is impossible to add a reference to unmanaged C++ project from C# project, afaik. How do i ensure correct build order if a solution contains unmanaged and managed projects? ...
How to turn stream from Named Pipe into Socket Stream? (in on Windows) (Share all new data in pipe stream on socket)? ...
Hello, i have 4 digital cams, the distance between every cam is 30 CM, i need a software or a programming library that works on c++ or Java, that can take videos from these 4 cams, and put them in one video showing only one image that is gathered from the 4 cams, any hints would be helpful, Thanks anyway. ...
I've written my own code to parse an .obj model file - essentially just ASCII text. The file gets parsed and stored in the class correctly according to my tests. I can read back the values (from data members) just fine in the loading function. The problem occurs when I try to read back the values in my main rendering loop. There is an a...
What type T makes the following code compilable? T f(){ return &f; } I'd prefer a C answer, but I marked the question as C and C++ in case there is only an answer using templates. ...
I'm trying to make extensive tests for my new project but I have a problem. Basically I want to test MyClass. MyClass makes use of several other class which I don't need/want to do their job for the purpose of the test. So I created mocks (I use gtest and gmock for testing) But MyClass instantiate everything it needs in it's constructo...
I received homework to make program without casting using constructors so this is my code, I have two classes: class Base { protected: int var; public: Base(int var = 0); Base(const Base&); Base& operator=(const Base&); virtual ~Base(){}; virtual void foo(); void foo() const; operator int(); }; class Der...
I've been using std::istream and ostream as a polymorphic interface for random-access binary I/O in C++, but it seems suboptimal in numerous ways: 64-bit seeks are non-portable and error-prone due to streampos/streamoff limitations; currently using boost/iostreams/positioning.hpp as a workaround, but it requires vigilance Missing opera...
Possible Duplicate: C++ Comma Operator what is result of operator ',' by standard? Last argument? in code like this, for example: int a = 0; int b = 1; while(a,b); or using it like this is not allowed? MSVS thiks that result is b, is it true? sorry for duplicating, did not know how this operator called in english ) ...
For reasons I completely disagree with but "The Powers (of Anti-Usability) That Be" continue to decree despite my objections, I have a sorting routine which does basic strcmp() compares to sort by its name. It works great; it's hard to get that one wrong. However, at the 11th hour, it's been decided that entries which begin with a number...
Suppose I have a bunch of fruit: class Fruit { ... }; class Apple : public Fruit { ... }; class Orange: public Fruit { ... }; And some polymorphic functions that operate on said fruit: void Eat(Fruit* f, Pesticide* p) { ... } void Eat(Apple* f, Pesticide* p) { ingest(f,p); } void Eat(Orange* f, Pesticide* p) { peel(f,p); ingest...
We have a message processing system with high performance demands. Recently we have noticed that the first message takes many times longer then subsequent messages. A bunch of transformation and message augmentation happens as this goes through our system, much of it done by way of external lib. I just profiled this issue (using cal...
In my code, I have the following: ostream_iterator<double> doubleWriter(cout, " ~ "); // ... *doubleWriter = 1.1; doubleWriter++; *doubleWriter = 2.2; *doubleWriter = 3.3; // shouldn't 2.2 be overwritten? doubleWriter++; *doubleWriter = 44.2; cout << endl << endl; I expected it to output this: 1.1 ~ 3.3 ~ 44.2 ~ Instead, the outp...
Hi, I have a framework that I am building and is being compiled into a static library to be used by other projects. The library works perfectly without issues. The problem is that the link time is very long for the projects that use the library so I thought I will make a DLL project of the same framework. I started with baby steps and ...
I have a question about the following code: #include <iostream> #include <boost/scoped_ptr.hpp> class Interface { }; class A : public Interface { public: A() { std::cout << "A()" << std::endl; } virtual ~A() { std::cout << "~A()" << std::endl; } }; Interface* get_a() { A* a = new A; return a; } int main(...
I have a struct Foo. In pseudocode: def FindFoo: foo = results of search foundFoo = true if a valid foo has been found return foo if foundFoo else someErrorCode How can I accomplish this in C++? Edited to remove numerous inaccuracies. ...
I need to change the C++ code to connect with WebSphere MQ using Client Channel defnition table. There are about 5000+ MQ clients and 10 MQ Servers on Windows 2003 with v6.0. Please help me if any one using C++ with CCDT. ...