c++

How to better initialize a reference counter for a non-creatable COM object?

I have a COM interface with a method that returns an object: interface ICreatorInterface { HRESULT CreateObject( IObjectToCreate** ); }; The key is that calling ICreatorInterface::CreateObject() is the only way to retrieve an object implementing IObjectToCreate interface. In C++ I could do it this way: HRESULT CCreatorInterface...

Margin in popup menu (qt3)

Is there any method to get rid of the huge margin on the right side? It appears to be constant, because adding some text to the menu items doesn't change its width at all. ...

Why building the same project generates different EXE file for each developer

My team and I are developing a VC++ 6 project. We are all using the same code-base (using version control system), and all our compiler/linker/environment-settings (including include directories order), as far as we can tell, are exactly the same. Of course we are using the same VC++ version with the same service packs (VC6 SP6). The pr...

Qt: How to connect QScriptEngineDebugger to QScriptEngine in separate thread?

I need to process script in separate, non-GUI thread since script calls C++ function that can take very long time to process (seconds). Is it possible to connect QScriptEngineDebugger to my QScriptEngine in non-gui thread? The problem is - if I put QScriptEngineDebugger in same thread as QScriptEngine (non-gui) than debugger will crash ...

how to deal with a static analyzer output

We have started using a static analyzer (Coverity) on our code base. We were promptly stupefied by the sheer amount of warnings we received (its in the hundreds of thousands) , it will take the entire team a few months to clear them all (obliviously impossible). the options we discussed so far are 1) hire a contractor to sort out th...

Object oriented programming , inheritance copy constructor

Suppose i have a base class "person". and i publically inherits a class "student " from the base class "person". i have not written the copy constructor for base and the derived class. now suppose i write in the main program main() { student sobj1("name", "computer science"); student sobj2=sobj1; } now in the second line the default ...

Drag Drop using SendMessage

hi guys, This sounds funny..just a little experiment. i wanted to simulate a drag drop of a file on a Application/Window using Send Message. Is it possible? I dont have code for the application but on the executable. The application is IP Messenger. What i wanted to do is use "Send To" functionality to send the file to an .exe ,which ...

How to speed up rotated text output in MFC

I have a MFC application that displays annotated maps, which can include a large amount of text. While the size and font of the text does not tend to change much, the rotation of the text varies considerably, in order to be aligned with the surrounding line work. This basically means that I have to do create and select a new font into ...

CryptGenRandom to generate asp.net session id

Hi! does anyone have working example of CryptGenrRandom class to generate session id (need to use in my iis module). HCRYPTPROV hCryptProv; BYTE pbData[16]; if(CryptAcquireContext( &hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { if(CryptGenRandom(hCryptProv, 8, pbData)) { std::st...

main function does not return anything. Why?

Hi, With respect to C/C++ main() must always return an integer(zero to indicate success and non-zero to indicate failure). I can understand this as the program is run it becomes a process and every process should have an exit status, which we obtain by doing echo $? from shell after the process gets over. Now I don't understand why is...

Cocoa and Objective-C++

Hey guys! I think I understand how Objective-C++ works in relation to Cocoa, and I am fairly versed in the basics of command-line C++ but sort of afraid to try mixing it with Objective-C. I can create a GUI with Interface Builder in Xcode, and even make classes (.h and .m files) for the interface automatically. The outlets, maybe action...

Mmimic C++ template functions in Java

Hi, In C++ I can write a template function that takes the data type on which to act as an argument, so that a single function can be reused for more than on data type. Is there a provision for doing a similar thing in Java? Thanks, Roger ...

Calling a subclassed virtual method from a base class method

class A { public: virtual void doSomething(void) {} void doStuff(void) { doSomething(); } }; class B : public A { public: void doSomething(void) { // do some stuff here } }; B * b = new B; b->doStuff(); It gives me Segmentation fault. What am I doing wrong? It s...

Returning from a multimap search with equal_range without being error-prone

I'm about to refactor some duplicated code. Two functions both search in a multimap using equal_range(). In a for loop after the call to equal_range() there is a for loop that sets an iterator to equalRange.first with the condition it != equalRange.second. If the correct value is found, the two functions differ. What I would like to do...

my_thread_global_end threads didn't exit, error?

I am using MySQL c++ connector (1.0.5) , recently I moved get_driver_instance() and connect() methods to secondary thread then I am getting below error. Error in my_thread_global_end(): 1 threads didn't exit After googling I found that mysql thread isn't exiting. Is there a method in c++ wrapper to do cleanup? ...

Netbeans 6.8 C++ IDE: program crashes while debugging in cygwin on windows

Whenever I try to debug my project in Netbeans 6.8 C++ IDE with cygwin on windows, it gives me the message window "Application crashed".(Netbeans IDE does not crash but only my program)There is no problem while running only, but while debugging, it crashes. Please help ...

How to display exception message of managed C# code in c++ code

Iam calling the functions using SMO of a c# dll in a c++ project but the code in that dll is throwing some exception, so how can I display the exception message in my C++ code ...

Memory analysis for a process

Hello guys I have a process which calls/creates another process, and this one will load a bunch of modules. The thing is that these modules will all be loaded in the same process as the caller (by default). Is there any way that I can collect resources information for the individual loaded module, even through they are all on one big p...

delete this pointer behaviour in g++

#include <stdio.h> class Foo { public: Foo(char x); Foo(char x, int y); ~Foo(); void abc(); void dev(); }; void Foo::dev() { printf("inside dev \n"); } void Foo::abc() { printf("inside abc \n"); delete this; dev()...

Does the following code invoke UB ?

Does the following code invoke UB ? int main(){ volatile int i = 0; volatile int* p = &i; int j = ++i * *p; } ...