c++

How do i sort objects?

Hello everyone, I've created a class and created an array of objects under that class and filled it all up with data. Now i want to sort the entire array by a specific member of that class, how do I do this using the stable_sort() function? Edit: Ok, i have this right now, class sortContiner { public: double position; int ke...

How do you disassemble an overloaded operator in gdb?

If I have something like bool operator ==(const uint128& x, const uint128& y); how can I get gdb to disassemble it? ...

How do I convert double to string using only math.h?

I am trying to convert a double to a string in a native NT application, i.e. an application that only depends on ntdll.dll. Unfortunately, ntdll's version of vsnprintf does not support %f et al., forcing me to implement the conversion on my own. The aforementioned ntdll.dll exports only a few of the math.h functions (floor, ceil, log, p...

Socket in use error when reusing sockets

I am writing an XMLRPC client in c++ that is intended to talk to a python XMLRPC server. Unfortunately, at this time, the python XMLRPC server is only capable of fielding one request on a connection, then it shuts down, I discovered this thanks to mhawke's response to my previous query about a related subject Because of this, I hav...

Namespace + functions versus static methods on a class

Let's say I have, or am going to write, a set of related functions. Let's say they're math-related. Organizationally, should I: Write these functions and put them in my MyMath namespace and refer to them via MyMath::XYZ() Create a class called MyMath and make these methods static and refer to the similarly MyMath::XYZ() Why would I c...

variable-size type declared outside of any function

when declaring the two dimensional array int random[height][width]; and then using it in a function void populate(int random[height][width], int x, int y) gives the error variable-size type declared outside of any function. I know I'm doing something wrong, and that its something small. I just have a bad memory... ...

Detect what process/program start my process/program

Is there a way in code to detect what process or application starts my process or application. Any .net, vb6 or c++ code snips would be great ...

Sharing output streams through a JNI interface

I am writing a Java application that uses a C++ library through a JNI interface. The C++ library creates objects of type Foo, which are duly passed up through JNI to Java. Suppose the library has an output function void Foo::print(std::ostream &os) and I have a Java OutputStream out. How can I invoke Foo::print from Java so that...

Screensaver in C++ with fading image

How can I make a screensaver in C++ that fades an image in and out at random places on the screen with a specified time delay on the fade out? Multimonitor support would be awesome. If you have a working code or know where I can get it, it would be great. Otherwise point me in the right direction. I'm looking for a method that has a sm...

C++ syntax question: if var != type int

I am trying to write an if statement but cannot find the proper expression form to use. I'm thinking of writing something like this: if ( var != type(int) ) However, I am unsure exactly how to go about doing this, and this method does not work. Am I at least thinking along the right lines? ...

What is the best way to store and instantiate list of classes in C++ without using STL?

I have a code similar to the following: class News { public: virtual void get() = 0; } class Cnn : News { void get () {...} } class Msnbc : News { void get () {...} } class Bbc : News { void get () {...} } main () { News * news = new Cnn; news->get () News * news = new Msnbc; news->get () News * news = new Bbc; news...

Where to go from here

I have a basic understanding of C++ (and cicual basic, but I dont like it). I know the syntax, classes inheritance, pointers,m stuff like that. I can answer most basic exercises I come across and make simple programs like imperial/metric conversions and things like that. Best program I wrote (and I was chuffed with myself!) was a program...

is this function reentrant?

void reverse_string(char* string, int str_size) { char tmp; int i = 0; int j = str_size - 1; while (i < j) { tmp = string[i]; string[i] = string[j]; string[j] = tmp; ++i; --j; } } I think this function is reentrant, since it doesn't use any global variable. It only modifies th...

C Variable Scope Specific Question

Here is a particular scenario that I have been unclear about (in terms of scope) for a long time. consider the code #include <stdio.h> typedef struct _t_t{ int x; int y; } t_t; typedef struct _s_t{ int a; int b; t_t t; }s_t; void test(s_t & s){ t_t x = {502, 100}; s.t = x; } int main(){ s_t s; test(s); printf("value i...

C++ Process Checking

I'm creating a task-manager type application in C++, and I'm currently using: ` void MyFrame::ProcChecker(bool showmessage=false){ HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); PROCESSENTRY32 *processInfo = new PROCESSENTRY32; processInfo->dwSize = sizeof(PROCESSENTRY32); int index = 0; string procList = ""; ...

When should linkers generate multiply defined X warnings?

Never turn your back on C++. It'll getcha. I'm in the habit of writing unit tests for everything I do. As part of this I frequently define classes with names like A and B, in the .cxx of the test to exercise code, safe in the knowledge that i) because this code never becomes part of a library or is used outside of the test, name collisi...

C++ STL containers: what's the difference between deque and list?

What is the difference between the two? I mean the methods are all the same. So, for a user, they work identically. Is that correct?? ...

structure initialization

static struct Args { char* arg1; unsigned arg2; unsigned arg3; char* arg4; } arg; My program saves command line args to a structure. Sometime all of the members are set... sometimes only a couple of them. In the case where only arg1 is set, what would the best practice be to do with the rest of the members? Thanks. ...

In MFC program, how to pass data between different dialog?

In web development, when we want to pass something between different pages, we might use the Session to save the data. But in MFC, what can we use to store these things? Thanks! ...

in mfc how to implement dockable dialog?

i am working on a Dialog based application in MFC, I need something just like visual studio's left panel, right panel, bottom panelwhich have a close button to close the panel. Anyone know how to implement this ? ...