#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <utility>
#include <algorithm>
void * GetMemory(size_t n) {
void *ptr = malloc(n);
printf("getMem n %d ptr 0x%x\n", n, reinterpret_cast<unsigned int> (ptr));
return ptr;
}
void FreeMemory(vo...
Hey,
I'm looking for a standard dual-map structure - is there one implemented in std/boost/another standard C++ library?
When I say "dual-map" I mean a map which can be indexed efficiently both by the key and the "value" (it actually has two key types instead of one key type and one value type).
for example:
dualmap<int,string> m;
m[1...
I store objects of a custom data type in QStandardListItems. I recover these objects by calling:
i.data(Qt::UserRole + 1).value<LiteReach>();
This only creates a new object in the stack. Any changes I do to them would be temporary.
Is there a way to get the base object stored in itemData so that it could be manipulated directly?
If n...
Hello,
I am developing a library in C++ where users/programmer will extend a class BaseClass that has a method initArray. This method should be implemented by the user/programmer and it should normally initialize all elements of the array m_arr.
Here is a snipplet, modified to this example:
class BaseClass {
public:
BaseCla...
Hi All.
I have written a COM dll, and wish to register it using
regsvr32 myComdll.dll
I get an error :
DllRegisterServer failed, Return code was: 0xc0000005
I want to debug my DllRegsiterServer function, but I do not know how to set up Visual Studio 2008 to run regsvr32 in debug mode...
Thanks
Roey
...
Hi,
I want to start working on a personal project and I want to make it cross-platform. All of my Linux work was done for business customers, so the target distro was specified in advance, but this is different.
The project will be open source and use Qt. Here's what I'm wondering:
Is it enough if I do my dev + testing on one distro...
Possible Duplicate:
In what cases do I use malloc vs new?
Duplicate of: http://stackoverflow.com/questions/184537/in-what-cases-do-i-use-malloc-vs-new/
and
http://stackoverflow.com/questions/808148/when-to-use-malloc-instead-of-new
Does anyone have real life programming scenarios where using "malloc" instead of "new" in C++ w...
I noticed that the sample apps from QT show their menu bar as opaque, and with a color that doesn't match any of the styling on the window. It seems as if the windows being created by QT when running on Vista or Windows 7 don't pick up the translucency that are no the mainstay of the new Windows look and feel. Is there a way to override ...
I'm sure I've just missed this in the manual, but how do you determine the size of a file (in bytes) using C++'s istream class from the fstream header?
...
Hi, quick question. Is there any way to (easily) retrieve the parent layout of a widget in Qt?
PS: QObject::parent() won't work, for logical reasons.
EDIT:
I'm positive the widget has a parent layout, because I added it to a layout earlier in the code. Now, I have many other layouts in the window and while it is possible for me to keep...
The examples for JNI i've seen map Java native methods to implementation by C++ global functions. Is there a way to set the native methods implementation to be the member functions of a C++ object instead?
...
I'm having a brain cramp... how do I initialize an array of objects properly in C++?
non-array example:
struct Foo { Foo(int x) { /* ... */ } };
struct Bar {
Foo foo;
Bar() : foo(4) {}
};
array example:
struct Foo { Foo(int x) { /* ... */ } };
struct Baz {
Foo foo[3];
// ??? I know the following syntax is...
I come from a C# background and I am working on a C++ project. I need to open files in a directory, then process that data in the files. The problem is on my target environment (Greenhills Integrity), I cannot access a "directory". It seems C++ does not have a concept of a directory. Why not? This problem is simple in C#. I cannot ...
Hi
I am doing mail parsing application which required to convert the HTML file to Plain Text.
regarding this i have found some scripts which does conversion.
I want to do same thing in C++.
So please suggest me any Cross platform and open source C++ libraries for converting HTML to Plain Text.
Thanks in advance
Regards
Subbi
...
So I can't use initializers in my class constructor because of using arrays, so I decided to use an init() method instead. Now I have a different problem. I have a class like this:
class EPWM {
private:
volatile EPWM_REGS* const regs;
public:
void init(volatile EPWM_REGS* _regs);
};
where I need to implement init() by initializi...
Hi! I'm using wxWidgets 2.8.9, built with the default settings under Windows XP, VC9. And I have absolutely standard EXE with IMPLEMENT_APP like this:
#include <wx/wx.h>
#include <wx/image.h>
#include "MainFrame.h"
class MyMainApp: public wxApp {
public:
bool OnInit();
};
IMPLEMENT_APP(MyMainApp)
bool MyMainApp::OnInit()
{
wx...
Hi all,
I load my music track using SDL_mixer function:
Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
For synchronization with video I need to know current music position.
How can I determine this?
...
I got the task to rewrite the library lwIP to OOP style, taking as an object stream, I began to understand, to climb into this library, but that's the problem:
src\include\lwip\arch.h include file cc.h (line 43) which can not find neither I nor the compiler
...
I have a quite complex class hierarchy in which the classes are cross-like depending on each other: There are two abstract classes A and C containing a method that returns an instance of C and A, respectively. In their inherited classes I want to use a co-variant type, which is in this case a problem since I don't know a way to forward-d...
Hello there,
I have a question regarding the following code snippet I came across in one of our older libraries.
try
{
throw "this is an error message";
}
catch( char* error )
{
cout << "an exception occured: " << error << endl;
}
My understanding of the behavior in this case is, that the error message is thrown by value, which m...