c++

Grouping MMC Snapins?

I have an MMC application written in Unamanged C++. It has the following orginization: MMC Plugin (Primary Snap-in) - Snapin A (Extension Snap-in) - Snapin B (Extension Snap-in) - Snapin C (Extension Snap-in) - Snapin 1 (Extension Snap-in) - Snapin 2 (Extension Snap-in) - Snapin 3 (Extension Snap-in) I would like to change...

Big O help

If i had a function like this... void myfunction(node* root) { for(int i = 0; i<root->children.size();i++) { myfunction(root->children[i]); } } granted thats just the part of the function I have a question on, but would that be n^2 or just n, for big O? I guess the question is if you have a for loop and inside that for...

How to Connect SVN server in C++

Hi Guys I wanna connect svn server and download one file from svn to my computer location by using C++ and writing this program. How can i make this? Thanks ...

How to get CPU usage or disk usage of application using Windows API from C++?

How to proceed to get CPU usage or disk usage of application using API in C++??? I want to get the highest CPU usage or disk usage among the application running on windows. I have tried to find out API but there is no direct API for that. Can anyone please let me know how to proceed for this in C++. ...

When is a C++ terminate handler the Right Thing(TM)?

The C++ standard provides the std::set_terminate function which lets you specify what function std::terminate should actually call. std::terminate should only get called in dire circumstances, and sure enough the situations the standard describes for when it's called are dire (e.g. an uncaught exception). When std::terminate does get cal...

Can C++/CLI be used to call .Net code from native C++ applications?

I've done the other way around (Calling pure C++ code from .Net) with C++/CLI and it worked (for the most part). How is the native->c++/cli direction done? I really don't want to use COM interop... ...

Is there a pattern which names managing evil static_casts

The following code is a simplified version of what I use for event dispatching. The essential point is that there is a static_cast<T*> on the argument of a template functor and another class makes sure that the argument passed to the functor is what the static_cast casts to. struct AbstractArg { virtual ~AbstractArg() { } }; struct...

In C++, how to get the address in which the value of a class instance's field is stored?

class A { public: int i; }; A *a = new A(); How to get the address of a->i? I tried &a->i and also &(a->i) but those generate compile time errors: "left of '.i' must have class/struct/union type" ...

MFC Control in a Qt Tab Widget

I'm working on a project that is using the Qt/MFC Migration Framework and I'm trying to reuse some existing MFC controls inside of a Qt dialog. Does anyone know if it is possible to insert an MFC control (CDialog or CWnd) inside of a QTabWidget. Right now we're doing the opposite, we have an MFC dialog with a tab control which is popula...

true isometric projection with opengl

Hello, I am a newbie in OpenGL programming with C++ and not very good at mathematics. Is there a simple way to have isometric projection? I mean the true isometric projection, not the general orthogonal projection. (Isometric projection happens only when projections of unit X, Y and Z vectors are equally long and angles between them a...

why is set_intersection in STL so slow?

I'm intersecting a set of 100,000 numbers and a set of 1,000 numbers using set_intersection in STL and its taking 21s, where it takes 11ms in C#. C++ Code: int runIntersectionTestAlgo() { set<int> set1; set<int> set2; set<int> intersection; // Create 100,000 values for set1 for ( int i = 0; i < 100000; i++ ) ...

C++ code and objects from C?

Is there a simple way to work with C++ objects directly from C? I want to expose some classes from C++ to C or to FFI(foreign function interface). Sure, I can write a stuff like that: class Foo{ .... }; void *make_foo(...){ Foo *ptr = new Foo(..) return static_cast<void *>(ptr); } .. int *foo_method1(void *fooptr, ...){ Foo *ptr = s...

Call different classes in different time in same function

I just cannot imaginate a way to do a call to a function with genericity. I have a code which a have to call a function in two different classes in different moments. I have A and B classes which I can access one time or other time. Or I access A or I access B. Not both in the same type. I have code this program but I just cannot imag...

SetThreadLocale and UTF8

So I want to use SetThreadLocale to set a threads codepage to UTF8. Up to now, I've been using the second parameter of atl string conversion macros like "CT2A(szBUF, CP_UTF8)" to do this. But I want to be able to set the thread codepage once in the beginning with SetThreadLocale() and never have to use the second parameter of the conver...

How to use stdext::hash_map where the key is a custom object?

Using the STL C++ hash_map... class MyKeyObject { std::string str1; std::string str2; bool operator==(...) { this.str1 == that.str1 ... } }; class MyData { std::string data1; int data2; std::string etcetc; }; like this... MyKeyObject a = MyKeyObject(...); MyData b = MyData(...); stdext::hash_map <MyKeyObjec...

Default value to a parameter while passing by reference in C++

Is it possible to give a default value to a parameter of a function while we are passing the parameter by reference. in C++ For eg. when i try to declare a function like virtual const ULONG Write(ULONG &State = 0, bool sequence = true); when i do this it gives an error error C2440: 'default argument' : cannot convert from 'const i...

C++ code in iPhone app

I'm trying to use a C++ library (CLucene) from my Cocoa Touch iPhone application using Xcode 3.1.3. Everything works fine when I run in the iPhone simulator, but things get strange when I run on device. It seems like pointers aren't being passed correctly from the Objective-C++ code (my app) to the C++ library (CLucene). While debuggin...

Interface/Superclass for Collections/Containers in c++

I'm coming from the Java world and are building a small c++ program at the moment. I have an object that does some work and then returns the result of the work as a list. Now a day later i changed the behavior of the object to save the results in a set to avoid duplicates in the container. But I can't simply return the set because I us...

P/Invoke Struct with Pointers, C++ from C#

I'm attempt to call a C++ dll with a struct and function like struct some_data{ int size,degree,df,order; double *x,*y,lambda; }; extern "C"{ __declspec(dllexport) double *some_func(some_data*); } from C#: [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] pu...

Compiler warnings

Suppose I have this (C++ or maybe C) code: vector<int> my_vector; for (int i = 0; i < my_vector.size(); i++) { my_vector[i] = 0; } I don't care if it's done right. The important part is in the for-loop declaration. The compiler gives a signed/unsigned mismatch for this, since size() returns an unsigned int, not a signed one. How i...