c++

How do I add controls other than buttons/actions to toolbars in Qt, such as text boxes and combo boxes?

From the screenshot featured on this page http://www.kde.gr.jp/~ichi/qt/designer-manual-3.html it seems like this functionality was available in Qt3. Was it removed in Qt4? ...

Boost multi_index_container crash in release mode

I have a program that I just changed to using a boost::multi_index_container collection. After I did that and tested my code in debug mode, I was feeling pretty good about myself. However, then I compiled a release build with NDEBUG set, and the code crashed. Not immediately, but sometimes in single-threaded tests and often in multi-thr...

C++ pass enum as parameter

If I have a simple class like this one for a card: class Card { public: enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES }; Card(Suit suit); }; and I then want to create an instance of a card in another file how do I pass the enum? #include "Card.h" using namespace std; int main () { Suit suit = Car...

Is it possible to call an object method this way in C++?

Here's my class definition: class A { public: void do_lengthy_work() { cout << "working." << endl; } }; I have an object of type A, and I want to call do_lengthy_work() on it: A a; a.do_lengthy_work(); Is it also possible to call the same method using some variant of the following? A::do_lengthy_work(a)...

How does Photoshop (Or drawing programs) blit?

I'm getting ready to make a drawing application in Windows. I'm just wondering, do drawing programs have a memory bitmap which they lock, then set each pixel, then blit? I don't understand how Photoshop can move entire layers without lag or flicker without using hardware acceleration. Also in a program like Expression Design, I could hav...

Risking the exception anti-pattern.. with some modifications

Lets say that I have a library which runs 24x7 on certain machines. Even if the code is rock solid, a hardware fault can sooner or later trigger an exception. I would like to have some sort of failsafe in position for events like this. One approach would be to write wrapper functions that encapsulate each api a: returnCode=DEFAULT; try...

stl string return by const reference vs. const char*

i have a STL string member variable in my class, class A { public: const char* getData1() const { return data.c_str()); const string& getData2() const { return _data; } private: string _data; }; getData1() vs. getData2(), which one is better? ...

User Defined Class as a Template Parameter

Hi, I' m implementing a custom STL map. I need to make sure that any data type (basic or user defined) key will work with it. I declared the Map class as a template which has two parameters for the key and the value. My question is if I need to use a string as the key type, how can I overload the < and > operators for string type keys o...

C++ book for a c# developer

I am a c# developer which finds himself having to relearn c++. The last time I programmed in c++ was in school and am looking for good books as a refresher. I want something that assumes previous programming exposure and gets straight to the point. Is there a book similar to K&R for c++? I know the language is bloated so a book that cove...

how can udp data can passed through RS232 in ansi c?

i want to transmit and receive data on RS232 using udp and i want to know about techniques which allow me to transmit and receive data on a faster rate and also no lose of data is there? thanx in advance. i have tried but need improvements if possible #include <stdio.h> #include <dos.h> #include<string.h> #include<conio.h> #includ...

Image rotate opecv error

When I use this code to rotate the image, the destination image size remains same and hence the image gets clipped. Please provide me a way/code snippet to resize accordingly (like matlab does in imrotate) so that image does not get clipped and outlier pixels gets filled with all white instead of black. I dont image to be scaled down to ...

Access Violation in std::pair

I have an application which is trying to populate a pair. Out of nowhere the application crashes. The Windbg analysis on the crash dump suggests: PRIMARY_PROBLEM_CLASS: INVALID_POINTER_READ DEFAULT_BUCKET_ID: INVALID_POINTER_READ STACK_TEXT: 0389f1dc EPFilter32!std::vector<std::pair<unsigned int,unsigned int>,std::allo...

Specialization of template method - what's wrong with my code?

What's wrong with this code? class School { public: template<typename T> size_t count() const; private: vector<Boy*> boys; vector<Girl*> girls; }; template<> size_t School::count<Boy>() const { return boys.size(); } My compile says error: specialization of ‘size_t School::count() [with T = Boy]’ after instantiation ...

Inheritance and static variables

Here is my code - #include <iostream> #include <conio.h> using namespace std; class Base { public: int a; }; //int Base::a = 5; class Derived : public Base { public: int static a; }; int main() { Derived d; cout<<d.a; getch(); return 0; } I get a linker error here. But when I do it the other way round - class Bas...

Can you recommend an interesting driver application that's fit for novice?

I'm totally new to driver development, seeking of an interesting driver related task to get started. ...

OpenAL - determine maximum sources

Is there an API that allows you to define the maximum number of OpenAL "sources" allowed by the underlying sound hardware? Searching the internet, I found 2 recommendations : keep generating OpenAL sources till you get an error. However, there is a note in FreeSL (OpenAL wrapper) stating that this is "very bad and may even crash the l...

Containers of auto pointers

I know containers of auto pointers should not be used and can cause problems. What is the actual reason for that? Is there any other kind of "smart" pointer which is safe to use in a container? ...

Implement Hardware Acceleration for Graphics in Silverlight for Windows Embedded

Does anyone have any sample code to how to use DDraw & OpenGL in wince? I have searched the net and I didn't find anything on how to implement hardware acceleration in wince using DDraw & OpenGL. Please guide me how to use OpenGL API in wince 6.0 r3 for implementing hardware acceleration. I want to know the steps regarding how to u...

Can libnet be used to inject tcp packets/packet mangling?

I just took a glance at the introduction of libnet, seems it mentioned support for udp,*ip*,but not tcp? Does it support tcp at all? ...

Is throwing an exception a healthy way to exit?

I have a setup that looks like this. class Checker { // member data Results m_results; // see below public: bool Check(); private: bool Check1(); bool Check2(); // .. so on }; Checker is a class that performs lengthy check computations for engineering analysis. Each type of check has a resultant double that the...