c++

MessageBox does not work in a catch of an exception

Well I have 2 issues but my main concern right now is my catch exception. Here is the code... int GXRenderManager::Ignite(HINSTANCE * hinst, int * nCmd, GXDEVICE DeviceType, int width, int height) { try { GXRenderManager::hinstance = hinst; GXRenderManager::nCmdShow = nCmd; GXRenderManager::height = height; GXRenderManager::w...

What's the standard way of trapping system messages in Qt4?

I've been looking for a way to trap and retrieve system messages in Qt4, specifically the WM_DEVICECHANGE messages among others. I know how to in C# but can find any conclusive text on how to in Qt4. Thanks in advance.. ...

How does sizeof work? How can I write my own?

I know C++ and know the function sizeof itself but I need to write my own sizeof function so please explain how it works exactly? What does it do with the parameter? ...

When should I use do-while instead of while loops?

Possible Duplicates: Is there ever a need for a do {} while ( ) loop? Do your loops test at the top or bottom? While vs. Do While When is a do-while appropriate? I've been having a philosophical debate with a colleague as to whether as a general rule, in C/C++ we should should use while loops rather than do-wile loops. ...

How to use Enum with strings in a function?

Basically, I have a Linked List which implements a display()function that simply loops throught he elements and prints out their values. I wanted to do it like this: void List::display( std::string type ) { switch(type) { // Do stuff... The compiler immediately complained. My teacher said this would be because the strin...

How to monitor/show progress during a C++ sort

I'm planning to write an interactive C++ geometry processing plug-in that will frequently sort large amounts of data. Although preliminary indications are that the sort will take only a second or two, I'd prefer to show progress during that time - i.e I'd like to update a progress indicator a few times per second. This would be prefera...

How to add a QAction to specific position in a QToolBar

QToolBar::insertWidget allows to add a QWidget after a specific QAction. Is there any way to add a QAction at a specific position? Removing all actions and then re-adding them again after is my last hope ! ...

Incorrect data input with fstream

I tried to read in data from a text file using fstream but got wrong data. ifstream fin ("C:\\Users\\rEgonicS\\Documents\\test.in"); int number; fin >> number; cout << number; test.in is simply "12". cout reads 4273190. Can someone explain why this is so and how to fix it? Thanks in advance. *Stackoverflow thought I was a bot ; o ;...

min and perfect forwarding

The min algorithm is normally expressed like this: template <typename T> const T& min(const T& x, const T& y) { return y < x ? y : x; } However, this does not allow constructs of the form min(a, b) = 0. You can achieve that with an additional overload: template <typename T> T& min(T& x, T& y) { return y < x ? y : x; } What ...

iterator_traits: code from Effective C++, Item 47 and TCPPSL, Section 7.5.1

This is going to be rather long, so I apologize preemptively. Near the end of Item 47 in Scott Meyers's "Effective C++" (Third Edition) he shows the following code: template<typename IterT, typename DistT> void advance(IterT& iter, DistT d) { doAdvance( iter, d, typename std::iterator_traits<IterT>::...

I have some circularities in my template class definitions.

I have a matrix class that takes the row and column reference type that can be used to access it as template parameters. Meanwhile, the row and column types are passed the matrix type that they are representing. Is there any way to break this circularity? Here are some demonstrative code snippets: #include "MatrixConcreteType.h" temp...

VS2010 debugger takes an unreasonable amount of time

Anyone else dealt with VS2010 debug in C++ and have it just sit there for 30+ second each time you step? This is happening to me and the call stack window just has this grey thing that says "Busy..." in it during this freeze. The whole interface just locks down...each and every step I make and right now I'm trying to step through this ...

C++ SFML "unable to initialize application 0xc000005"

I wrote a wrapper for SFML that would allow me to replace the renderer for my game if I needed to. It worked. Then I refactored and while it still compiles, I now get "unable to initialize application 0xc000005" when running the compiled executable. What would cause such an error? Google was unhelpful. I'm using Windows XP. ...

preventing unaligned data on the heap

I am building a class hierarchy that uses SSE intrinsics functions and thus, some of the members of the class need to be 16-byte aligned. For stack instances I can use __declspec(align(#)), like so: typedef __declspec(align(16)) float Vector[4]; class MyClass{ ... private: Vector v; }; Now, since __declspec(align(#)) is a compilation ...

Check if string contains a range of numbers

I'd like to test a std::string for containing numbers of any range e.g 5 to 35 in a std::string s = "XDGHYH20YFYFFY" would there be function or I would have to convert a number to string and then use a loop to find each one? ...

Social networking APIs and C/C++

Folks, Note sure if this is the best place to ask this one, but I doubt there'd be a better place. I see that github, stackoverflow, facebook, twitter, linkedin etc. have been providing developer API to slice and dice user information. Couple of questions on the general nature of these API: 1) Are these open-source? 2) Is there any ...

Options for granting access to class data members (C++)

This is a basic question about what options are available for defining the scope of some parameters. I'd particularly like to have a sense of the tradeoffs in speed, memory, code clarity, ease of implementation, and code safety. My programming experience is clearly modest, and I have little formal training. I suspect one or two options w...

Usage of this pointer

I have a question relating to the usage of "this". Suppose I have two classes A & B; their rough outline is as follows: class A { public: ... void AddB( B* b ) { // inserts B into the vector v } private: std::vector<B*> v; }; class B { public: ... void foo( void ) { ... // Adds itself to th...

LINK : fatal error LNK1104: cannot open file '..\json_spirit\Debug\json_spirit_lib.lib'

Can someone point me in the right direction? I'm not a C++ or VS developer but I'm trying to compile a project and I'm getting the above error. I don't have any clue why the compiler is looking for that file or what the Debug folder is about (though I could guess). Can somebody explain the issue in other words for me and give me some ...

OSX, static variable sharing same address

In OSX I have the following code. Using gcc 4.0.1. I'm new to OSX development so I'm not sure what other system information would be useful here... static int textstrArgs[] = { 1, 1, 1 }; void func() { static int first = 1; if (first) { first = 0; // stuff } /* other stuff */ } where func() is ...