c++

Extract subset from boost dynamic_bitset

I need to extract and decode the bits (idx, idx+1, ... idx+n_bits) from a given boost dynamic_bitset. I have created the following solution: boost::dynamic_bitset<> mybitset(...); // build mask 2^{idx+n_bits} - 2^{idx} const boost::dynamic_bitset<> mask(mybitset.size(), (1 << idx+n_bits) - (1 << idx)); // shift the masked result idx tim...

Zooming in and out in Direct3D

Hello, I have a 3D scene and I want to be able to zoom in and out. What implementations are good, and which has some flaws? Will I be changing viewport, clipping panes? I totally don't know. Thanks ...

Derived to base class conversion

How does the conversion between derived and base class internally occurs and how does compiler knows or does it store the size of object? For example in the following: class A { public: A():x(2){}; private: int x; }; class B : public A { public: B():A(),y(5){}; private: int y; }; class C : public B { public: C():B(),z(9){}; priv...

which c++ free lib to use to capture microphone sound and save it to wav

i saw i have 2 major lib's ( mybe i wrong ) 1. port Audio 2. openAl + cAudio wrapper what is easer and faster to use for cross platform ? ...

Why is there a delete[] in C++?

Why is there a delete[]? From my understanding its to behave differently for arrays. However, why does it really exist? Theres only free in C and no free_array. Also in syntax the only difference between delete var and delete []var is the [] which has no params (i'm not telling the length of the array). So why does delete[] really exist...

gdb to debug double free not detected by valgrind (?)

About once every three times I run my program, malloc reports a double free error; e.g. myprogram(703,0xb06d9000) malloc: *** error for object 0x17dd0240: double free *** set a breakpoint in malloc_error_break to debug I've run the same code through valgrind more than a dozen times but it never reports a double free. I ran the code t...

How can i write something to file at the end of the file in c++

Hello, i'm writing something to file and it writes it in the middle of the file, is there any function that writes output to the end of the file? thanx in advance. ok this is really wierd i'm running with the visual studio debugger and i see that it writes thing to file like this : A B C D which is good, and than when i'm writing somethi...

C++: const reference, before vs after type-specifier

What is the difference between the arguments in: int foo1(const Fred &arg) { ... } and int foo2(Fred const &arg) { ... } ? I don't see this case covered in the parashift FAQ. ...

C++ template and inline question

Hello! When I'm writing a simple (non-template) class, if the function implementation is provided "right in place", it's automatically treated as inline. class A { void InlinedFunction() { int a = 0; } // ^^^^ the same as 'inline void InlinedFunction' } What about this rule when talking about template-based classes? template <...

Can you explain what's symbols and debug symbols in c++ world?

Is it true that binary files like executables are composed of symbols and debug symbol is one kind of them? How to understand the symbol? ...

How to fire a JavaScript event via C++ in QWebView

Hi, please note that I'm a complete beginner to Qt development. I have a QWebView with a QObject added to the JavaScript window object. How do I fire a JS event on that object? view->page()->mainFrame()->addToJavaScriptWindowObject(objName,obj); I want to be able to listen to events using addEventListener. window.objName.addEventLis...

C++ visual studio inline

Hello! When building projects in Visual Studio (I'm using 2008 SP1) there is an optimizing option called Enable link-time code generation. As far as I understand, this allows specific inlining techniques to be used and that sounds pretty cool. Still, using this option dramatically increases the size of static libraries built. In my cas...

undefined reference error

hey, i got undefined reference error from my main function, but i can not find the problem. my files are: //Student.h #ifndef STUDENT_H #define STUDENT_H #include <vector> #include <string> class Student{ public: Student(std::string &line); ... virtual void evaluateValue(){} virtual ~Student(){} .... }; #endif //HeStudent.h #ifndef...

Consequences of only using stack in C++

Lets say I know a guy who is new to C++. He does not pass around pointers (rightly so) but he refuses to pass by reference. He uses pass by value always. Reason being that he feels that "passing objects by reference is a sign of a broken design". The program is a small graphics program and most of the passing in question is mathematical...

Draw over QLabel inside QScrollarea

Hi, I'm developing an image viewer, based on a QScrollArea and a QLabel that contains the image to show. Now, I need to show text over the label, like the current mouse (x,y) position, image size, etc., in a specific point, but it can't be affected by the scrolling. How can I do this? ...

Visual Studio 2010's strange "warning LNK4042"

I've just been beaten (rather hardly) on the head by some non-trivial warning from Visual Studio 2010 (C++). The compilation gave the following output: 1 Debug\is.obj : warning LNK4042: object specified more than once; extras ignored 1 Debug\make.obj : warning LNK4042: object specified more than once; extras ignored 1 Debug\view...

accumulation error

I have quite straight forward question. The following code prints out celsius and fahrenheit. My question is though about number of times it iterate. For a small number e.g. start 0, stop at 10, with a step of 1.1. After the loop is finished it will print out the correct number of iterations it made. But for large number 0-11000000, wit...

GTK theme engine: where to start?

I would like to start coding a gtk theme engine, but i'm wondering where i can find some documentation, if any exists. I know how to have look at someone else engine's code, examples, or torture tests and widget factories etc.., what i want instead is any documentation type, design, references, examples or tutorials possibly from reliabl...

What is the deal with undefined symbols in a shared library or dylib?

I have a Makefile for linux that I am porting over to Darwin. The makefile takes a bunch of .o files and links them together into a .so shared object. Okay, so I figured (am I wrong about this?) that the best analog for this in Darwin is the dylib. So I changed the -shared flag to -dynamiclib. Now the code that I am linking together ...

Doubting about the Threads window of visual studio

As you can see above , there are 4 win32 threads at exactly the same location, how to understand it? UPDATE 7C92E4BE mov dword ptr [esp],eax 7C92E4C1 mov dword ptr [esp+4],0 7C92E4C9 mov dword ptr [esp+8],0 7C92E4D1 mov dword ptr [esp+10h],0 7C92E4D9 push esp 7C92E4DA call 7C92...