c++

How do I call "operator->()" directly?

For some strange reason, I need to call the operator->() method directly. For example: class A { public: void foo() { printf("Foo"); } }; class ARef { public: A* operator->() { return a; } protected: A* a; }; If I have an ARef object, I can call foo() by writing: aref->foo(); However, I want to...

ExTAPI: lineRegister returns before line is registered

I am using the extended TAPI function lineRegister to register a GPRS radio on the network after powering the radio on using lineSetEquipmentState. The lineRegister function is returning successfully before the network is actually registered. The asynchronous lineRegister function first returns a positive number indicating the functi...

Overlay for 3rd party application

Hi, I'm looking for a way to display an overlay (hud) for a third party application on MacOSX. It should look like this. My working steps would be: find window by title get resolution of window create own invisible window check for moving events of target window I'm not very familiar with MacOS programming with Carbon and Cocoa and...

Simple recursion question.

Let's say we have a simple recursion like. int x(int a){ if(a<10) x(a+1); else !STOP! b++; return b; } Globaly: int b=0; In main we could have something like this: int p=x(1); Is there any way to stop the recursion so that the p will be 0, this means that "b++" will never be executed. I'll be grateful ...

C++ Pass by Reference Program

IBM explains C++ pass by reference in the example below (source included). If I changed void swapnum... to void swapnum(int i, int j), would it become pass by value? // pass by reference example // author - ibm #include <stdio.h> void swapnum(int &i, int &j) { int temp = i; i = j; j = temp; } int main(void) { int a = 10; ...

Ways to learn C++ for free?

I have a friend who wants to learn C++, but does not want to pay. I found Cplusplus tutorial, but I was wondering if there was any other material available for free. I've had a look at Thinking In C++, but I feel it may be a bit advanced (totally new person). Thanks. ...

What are the differences between the various boost ublas sparse vectors?

In boost::numeric::ublas, there are three sparse vector types. I can see that the mapped_vector is essentially an stl::map from index to value, which considers all not-found values to be 0 (or whatever is the common value). But the documentation is sparse (ha ha) on information about compressed_vector and coordinate_vector. Is anyone ...

Should I randomly shuffle before inserting into STL set?

I need to insert 10-million strings into a C++ STL set. The strings are sorted. Will I have a pathological problem if I insert the strings in sorted order? Should I randomize first? Or will the G++ STL implementation automatically rebalance for me? ...

Starting vg dev, which language?

Hey, I know someone who is looking into developing simple video games on his pc, and then eventually, hopefully port or develop some on the XBOX 360 indie center, using XNA studio. So, I have heard about C#? How easy it for a beginner? C++ is pretty good isn't it? But I've heard it's QUITE deep, broad, and sounds pretty easy to get l...

referencing a member function with bind1st and mem_fun

I have a C++ class where I'm trying to use std::bind1st to bind a member function to the 'this' parameter. For example: class MyClass { public: void Foo() { using namespace std; // this works fine this->Bar(); // this also works fine mem_fun( &MyClass::Bar )( this ); // this does not ...

gcc -O4 optimization flag

What's the meaning of the -O4 optimization flag in gcc (3.2.3)? What's the difference to O3? When would you use one vs. the other? The man pages only mention O, O0-3, Os, no word of the mysterious O4. Thanks! ...

why wasn't the idea of nested functions, implemented in older c++ standard?

was the idea of nested functions considered to be useless during the time of developing older c++ standard, because its usage is basically covered by another concept like object-oriented programming; or it wasn't implemented just as a matter of simplification? ...

Determine user & system time used by a thread

We have a qthreads-based workflow engine where worker threads pick up bundles of input as they are placed on a queue, then place their output on another queue for other worker threads to run the next stage; and so on until all the input has been consumed and all the output has been generated. Typically, several threads will be running t...

undefined reference with member implelementation of a templated class.

Hi! This is wholy mysterious to me. I'm using g++ on ubuntu, and this is some of my code (with class names change, but nothing else because I'm still using stubs everywhere): Bob.hpp template <class A> class Bob : public Jack<Chris, A> { public: Bob(int x1, int x2, float x3 = 1.0, float x4 = 2.0, float x5 = 3.0) throw(Exc...

msvcp90d.dll is missing msvcr90d.dll

I had a DLL project on one machine, and copied it to another with freshly installed VS2008. The project builds, but I cannot debug it. Dependecy Walker shows that my DLL sees msvcr90d.dll, but msvcp90d.dll does not see the same DLL. But if I open msvcp90d.dll in separate window then msvcr90d.dll is visible to msvcp90d.dll. This is obviou...

A better solution to Crypt Kicker?

While this seems like a duplicate of Crypt Kicker Problem, it isn't. I've solved the problem, but I'm not all together that satisfied with my solution. The problem statement is: A common but insecure method of encrypting text is to permute the letters of the alphabet. In other words, each letter of the alphabet is consistently replace...

C++ Runtime Error caused by adding new function (which isn't ever used beyond it's definition)

This has been stumping me for a bit. I have a Class written in C++. Everything works fine. Next, I add funtion void A(); to the header file and run, It still works fine. However as soon as I add a new function definition to the CPP file, I get a runtime error every single time. (specifically: Process terminated with status -1073741510 (...

Help with DLL to Lib

I have converted a dll to lib. I gave it the lib and dll file and told it to remove the unnecessary stuff. I #included the .h file it created, and called GLU_DLLMAIN() in InitInstance just like I saw in the samples, but it still crahes on start up when it tries to initialize my static GLU object. What am I doing wrong? what is the proper...

Convert ASCII string into Decimal and Hexadecimal Representations

I need to convert an ASCII string like... "hello2" into it's decimal and or hexadecimal representation (a numeric form, the specific kind is irrelevant). So, "hello" would be : 68 65 6c 6c 6f 32 in HEX. How do I do this in C++ without just using a giant if statement? EDIT: Okay so this is the solution I went with: int main() { st...

How do I set GNU G++ compiler in Visual studio 2008

How do I set my Visual studio 2008 compiler to GNU GCC. Can I also make it specific to projects? I didn't find any conclusive answer. Thank you. ...