c++

How to intercept keyboard shortcuts in GNOME

I want to write an application which will intercept some keyboards sequences (like those in Emacs – "C-c C-c") and run some function. How can I do this in GNOME? On wich level I should do that (kernel, X11, window manager)? ...

How can I call Nant scripts from Maven?

I'm working on a mainly Java based project, that also has a couple of components written in C++. The project is currently built using Ant scripts which invoke Nant to build the C++ components. We are in the process of moving to Maven and I was wondering if anyone could recommend the best way to build Nant scripts using Maven. I'm awar...

Misscreation of my template class causes errors with SOCKET, why?

Hey... I created a class which holds data of type and returns an vector on request. But somehow the following error occurs: error C2259: 'CAcceptor' : cannot instantiate abstract class due to following members: 'void CDataAndEvent<C>::InitQueue(void)' : is abstract with [ C=SOCKET ...

How to swap two numbers without using temp variables or arithmetic operations?

This equation swaps two numbers without a temporary variable, but uses arithmetic operations: a = (a+b) - (b=a); How can I do it without arithmetic operations? I was thinking with XOR ...

Is there a code formatter/beautifier usable from Netbeans

The code formatting option that Netbeans has is not customizable enough for C/C++. For example it has options to add spaces to binary operators, but I cannot specify which. So putting it ON results in: (a == b && b == c) and putting it OFF results in: (a==b&&b==c) What I would ideally like is: (a==b && b==c) Any suggestions on h...

recursive inline function

i have this files: //Q2a.h #ifndef Q2A_H #define Q2A_H inline int MyFactorial(int a) { if (a < 2) return 1; return a*MyFactorial(a-1); } int NumPermutations(int b); #endif //Q2a.cpp #include "Q2a.h" int NumPermutations(int b) { return MyFactorial(b); } and file with the main- Q2b.cpp i notice that the compiler usually ig...

Conventions for accessor methods (getters and setters) in C++

Several questions about accessor methods in C++ have been asked on SO, but none was able satisfy my curiosity on the issue. I try to avoid accessors whenever possible, because, like Stroustrup and other famous programmers, I consider a class with many of them a sign of bad OO. In C++, I can in most cases add more responsibility to a cla...

Handmade auto template (without using C++0x)

How can be realized the auto keyword functionality without using c++0x standard? for(std::deque<std::pair<int, int> >::iterator it = points.begin(); it != points.end(); ++it) { ... } Maybe such class: class AUTO { public: template <typename T1> AUTO(T1); template <typename T2> operator T2(); }; With such usage: ...

Is there a guarantee as to the size of a class that contains an array?

Given: template <int N> struct val2size { char placeholder[N]; }; Is there any guarantee that sizeof(val2size<N>) == N? ...

C++ - Set a class instance's function after it has already been defined

I am trying to give a class event functions such as .onShow() and .onHide(), so when the object is shown, the .onShow() function will run. How can I allow the function to be change like so: MyClass myInst = MyClass(); myInst.onShow = OnShowFunction; Is it possible to allow this? ...

Do you know a regular expression based parser in C++ that can be used to parse streams?

Hi, I would like to specify the regular expression during run-time, not compile-time. So that is why pcre falls out. Do you know C/c++ regular expression library that can parse streams and can recognise relatively complex regular expression such as .+? Thanks. ...

Error : C2143:syntax error : missing ';' before '.'

//// header file #ifndef _SECTION_ #define _SECTION_ #include <map> #include "Employee.h" using namespace std; class Section { private: char* m_sectionName; Employee* m_director; Employee* m_viceDirector; typedef multimap<string,Employee*> m_employees; public: Section (char* name); Section(const Section& section); ...

Objective C syntax inside .cpp file?

I'm trying to copy over some example code into my own project. The example project is iPhoneExtAudioFileConvertTest from the sdk. The example project contains a file called ExtAudioFileConvert.cpp. This file contains what looks like Objective-C code: assert([NSThread isMainThread]); The example project runs fine, but the compiler comp...

Segfaulting polymorphism (Suspected stack corruption - Code on github)

It's a little difficult to explain the offending piece of code, as there seems to be some degree of stack corruption, and all the code's pretty linked together (it's a game). If you're looking for a headache and some debugging, please check out the segfault branch on git://github.com/RobotGymnast/Gingerbread.git and see if you can find ...

memory layout of mutithreaded process in C++

Hi, Am a bit confused on how stack and heap are arranged in multithreaded processes: 1) Each thread has its own private stack. 2) All threads share the heap 3) When the program dynamically creates thread (ex: new Thread() in Java), the object is allocated on heap. so does the heap contain memory for thread object, which means does hea...

Role of model in MVC text editor scenario

I'm designing a movie script editing text editor for fun, and to try learn something about low level UI design. The format of a screenplay is quite simple, and is by long-standing standard written solely in 12pt courier. So I get the impression that designing an editor would be fairly straightforward, having only one font and font size...

adapting an old-fashioned cast of a std::streampos to be g++ 4.4 compatible

Good afternoon, I'm attempting to get some old-fashioned code to function in g++ 4.4. My understanding is the code compiled fine in g++ 4.0, but g++ has become more strict between 4.0 and 4.4. This code in particular causes the compiler to stop and complain: sprintf(s,"%.7d",(long)tellp()); tellp() is a std::streampos object. The ab...

Compiling for windows on linux

Is it possible to compile a Win32 program on a Linux computer without the use of an emulator or Wine or anything? ...

Collision detection between two general hexahedrons

I have 2 six faced solids. The only guarantee is that they each have 8 vertex3f's (verticies with x,y and z components). Given this, how can I find out if these are colliding? ...

Is there a value in preceding the names of pure virtual base classes with the letter 'I', as is common in C#/Java?

I don't see this very often, if at all, in C++. Any reason not to do this? I think it would be easier to identify the implications and intentions of the typename by doing this, as well as the sourcefile. Thoughts? ...