c++

Static initialization and destruction of a static library's globals not happening with g++

Hi! Until some time ago, I thought a .a static library was just a collection of .o object files, just archiving them and not making them handled differently. But linking with a .o object and linking with a .a static library containing this .o object are apparently not the same. And I don't understand why... Let's consider the following ...

How to receive drag and drop from Apple Address book in Qt 4.4 on Mac OS X 10.5/10.6

I am trying to trap drag and drop events from the standard Apple address book app to my Qt app. This code works fine with Qt 4.4. on Mac OS X 10.4: void MyView::contentsDropEvent( QDropEvent* e ) { QList<QUrl> urls = e->mimeData()->urls(); ... I can then use the URL to get the vCard. Marvellous. But from Mac OS X 10.5 the ap...

file search in c++

hey I just started learning c++ and am currently using codeblocks. i wanna write an application that can search for files in directory including it's subdirs, but i cant seem to find any good examples for this and i've read somewhere that this is only possible trough a library like boost. is this true? any examples for doing it withou...

Overload template relational operators

I'm having a problem with a template ARRAY class. I have another Rational class that i added to this ARRAY class. what i need it to do is take in rational numbers as fractions (exp 1/2) and sort them. i believe i need to overload the relational operators but thats where im stuck. do i over load them in the ARRAY class or the Rational Cla...

Extending enums in C++?

Is there a way in C++ to extend/"inherit" enums? I.E: enum Enum {A,B,C}; enum EnumEx : public Enum {D,E,F}; or at least define a conversion between them? ...

Which Linux software do you recommend for C++ programming?

I would like to learn to program using the Linux environment. What do you suggest for Editors/ IDEs? ...

c/c++ NLP library

I am looking for an open source Natural Language Processing library for c/c++ and especially i am interested in Part of speech tagging. ...

Multiple association problem with C++

How would you solve this problem? (At the beginning it seemed simple, then I found it to be puzzling). You have a class called Executor. Suppose you have many instance of it and they do different things upon call of a method do(Argument). Argument has 2 different parameters and they are A* pa, B* pb (one of which can be null) Now, I w...

Boost lib linker error Visual C++

I downloaded the source for Launchy and am trying to build it in Visual Studio 2005. The Launchy project is built using VC7 so I had to update the project files to VC8 and that process seemed to go well. However, Launchy also uses the Boost 1.33.1 libs and what I have built are the Boost 1.41.0 libs (props to Boost for making the more ...

I want to give a string a value of one.

I'm entering team names into a soccer league. I have an array set up so that the league can take at most 4 teams, I also have an array that states that the number of teams in the league is exactly 4 teams. So I want to set up a counter which stops me from entering too many team names. This is a small chunk of my code str teamName ...

C++ IDE with good intellisense

So I've been using Visual Studio 2008 for my C++ development for a while now, however the insanely crappy intellisense has been bugging me for ages. I'm looking for an alternative C++ IDE where the intellisense actually is reliable and doesn't vanish between the same variable, in the same scope, just on different lines. Any takers? ...

How to store a vector of LPD3DXSPRITE objects?

Let's say I want to store a vector of LPD3DXSPRITE objects. The line to declare this code would be std::vector<LPD3DXSPRITE> sprites; I should be able to create my sprite with: LPD3DXSPRITE sprite = NULL; D3DXCreateSprite(myRenderingDevice, &sprite); Finally, I should be able to add this to the vector like so: sprites.push_back(spr...

Socket available data for read

I need fast method for check socket has available data for read. I use select(), but it is not fast. Is faster method exists? ...

C / C++ Library for HTTPS Client with Basic Authentication

Do you recommend any good library or examples online for implementing an HTTPS client that can connect to a website using basic authentication? This is meant to run in linux servers. Any pointers help. Update: Question about the unanimous libcurl - does it come bundled by default in major distributions like Debian, Ubuntu, Gentoo, Slac...

Is this code legal in C++

I just found that when it comes to templates this code compiles in g++ 3.4.2 and works unless m() is not called: template <typename T> class C { T e; public: C(): e(0) {}; void m() { e = 0; }; }; Now one may create and use instance C<const int> c; Until c.m() is not called there are no compile errors b...

C++ extract polynomial coefficients

So I have a polynomial that looks like this: -4x^0 + x^1 + 4x^3 - 3x^4 I can tokenize this by space and '+' into: -4x^0, x^1, 4x^3, -, 3x^4 How could I just get the coefficients with the negative sign: -4, 1, 0, 4, -3 x is the only variable that will appear and this will alway appear in order im planning on storing the coefficients in ...

Does a boolean condition in a for loop that is always false get optimized away?

I have the following situation bool user_set_flag; getFlagFromUser(&user_set_flag); while(1){ if(user_set_flag){ //do some computation and output } //do other computation } The variable user_set_flag is only set once and only once in the code, at the very start, its essentially the user selecting what he want...

Vertical Scrollbar in CListCtrl

I'm using a CListCtrl in Icon view, but it scrolls horizontally: 1 3 5 7 --> 2 4 6 8 --> I'd rather it scroll horizontally: 1 2 3 4 5 6 | | V V Is there a way to do this? ...

Why isn't my virtual function working?

I have an abstract class called camera which PointCamera uses as its super class. For some reason one of the virtual functions throw an error in the debugger and tells me that it is trying to execute 0x00000000. This only happens if the function in question is the last one declared in the abstract class. If I switch the declaration order...

weird C++ constructor/copy constructor issues in g++

#include <iostream> using namespace std; class X { public: X() { cout<<"Cons"<<endl; } X(const X& x){ cout<<"Copy"<<endl; } void operator=(const X& x){ cout<<"Assignment called";...