Hello,
I have the following code using C++:
double value = .3;
double result = cos(value);
When I look at the values in the locals window for "value" it shows 0.2999999999
Then, when I get the value of "result" I get: 0.95533648912560598
However, when I run cos(.3) on the computers calculator I get: .9999862922474
So clearly there...
How often do you find yourself actually using spinlocks in your code? How common is it to come across a situation where using a busy loop actually outperforms the usage of locks?
Personally, when I write some sort of code that requires thread safety, I tend to benchmark it with different synchronization primitives, and as far as it goes,...
A few semesters back I had a class where we wrote a very rudimentary scheme parser and eventually an interpreter. After the class, I converted my parser into a C++ parser that did a reasonably good job of parsing C++ as long as I didn't do anything fancy with the preprocessor or macros. I could use it to read over my classes and function...
template <class Data, class Allocator = std::allocator<Node> >
class Node : public Data {
// ...
};
The question is simple, how to make the above code compile?
The intention is to give Node a possibility to allocate other Nodes (and to provide a default allocator).
...
I am working on a project that links to a 3rd party static library (herin refered to as EXTERNALLIB). In Visual Studio 2005 I was able to link to EXTERNALLIB and create a usable executable. Now we are using Visual Studio 2008 and I am receiving the following error:
fatal error C1047: The object or library file EXTERNALLIB was created ...
I've often wondered why C++ went with the name wchar_t instead of simply wchar, and I've never been able to find an answer. Search engines are no help because they think I'm asking about Windows' WCHAR type. Any ideas?
...
We are trying to create a widget of width larger than 2^15 pixels and the widget gets only black (no content shown) when we pass the 2^15 pixel barrier. Is there any documented maximum size limits imposed on widgets?
Any help is appreciated. Not only CE but I am interested in desktop Windows as well.
P.S: Using C++
...
When I try to create a class in managed C++ that inherits from ObservableCollection I get the error:
error C2039: 'ObservableCollection' : is not a member of 'System::Collections::ObjectModel'
Here's my code:
using namespace System;
using namespace System::Collections;
using namespace System::Collections::Generic;
using namespace Sys...
I subclassed CListCtrl into my own class, and I use it in several dialogs and views. What I want to do is execute some code when the ClistCtrl is being scrolled vertically. I need this to be in the CListCtrl subclass itself.
I can detect the scrolling triggered when interacting with the scrollbar with the method provided by demoncodemon...
I have a hook setup for getting mouse events in a plugin I develop. I need to get the WM_LBUTTONDBLCLK, and I expect the message flow to be:
WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK
If the I call the next hook when dealing with the first WM_LBUTTONDOWN, then the flow is as expected. However, if I return my own result, then the ex...
I am just beginning to learn how to write software that accesses an SQL server. It seems that each server implementation (Postgres, MySQL, etc.) offers API libraries for various languages (my code is in C and C++, though solutions for Java and Python would also interest me). I'm a little wary of depending on these libraries, however, b...
Where can I go to get information about the size of, say, unsigned int compiling under gcc for Mac OS X (both 32 and 64 bits)? In general I'd love to have a resource I can go to with a compiler/settings/platform/type and be able to look up how big that type will be. Does anyone know of such a thing?
Update: Thanks for all the responses....
** Sorry for the confusion regarding numCars in the original post. I modified the code to be consistent with the original ****
The following academic program is a simplified version of the original problem but it focuses on the issue that I have yet to resolve. There are 2 classes and a main method to this problem and the 2 classes cons...
I need to write a function that returns a value within an interval [a..b] after applying a delta.
void foo(a, b, val, delta);
Example1:
value = foo(0, 360, 120, -240);
value: 240
Example 2:
value = foo(360, 0, 60, 340);
value: 40
I have been able to code this behavior but I would like to compare my implementation with a (most likely)...
For one reason or another, I'm forced to provide both a copy constructor and an operator= for my class. I thought I didn't need operator= if I defined a copy ctor, but QList wants one. Putting that aside, I hate code duplication, so is there anything wrong with doing it this way?
Fixture::Fixture(const Fixture& f) {
*this = f;
}
Fi...
I was getting the following error compiling and iPhone project. Anybody know how I may fix it?
"vtable for oned::MultiFormatUPCEANReader", referenced from:
__ZTVN4oned23MultiFormatUPCEANReaderE$non_lazy_ptr in MultiFormatUPCEANReader.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
...
Do you know any Open source C++ Code Coverage tool that support a decent GUI to facilitate browsing the result?
Thanks.
EDIT: I forgot to mention, My code is developed Using MFC so I need a tool that supports Windows.
...
Hello,
I am currently running Windows Vista Home Premium, and I have developed an application with my friend using QT Creator. We are now trying to deploy our application as just one executable, so we are trying to do a static build. We have added CONFIG += static in our .pro file.
We are using this documentation to help us:
http://d...
I encountered following weird behavior yesterday. It seems a compiler bug to me or is there a something that I've missed? I was wrapping Facebook Connect for iPhone's Objective-C classes with Objective-C to C++ adaptor classes, so that they could be used from our own OpenGL/C++ code more conveniently.
The following code reveals the prob...
I wanted to know whether a 3D model library exists which is built upon opengl which i can use in my c/c++ code.
for eg ,is there a library where there are ready models of viz.apple,fan,football which i can directly draw using c/c++?
...