c++

how to free memory from a set

hey, i got a set that includes pointers to an allocated memory, i am using the clear method forexample : setname.clear(); and the set itself is getting cleared and his pointers but still i got memoryleaks the allocated memory stays uncleared for some reason. thanks in advance for your answer. ...

Add a node to an existing XML document

Hi everybody, I am working on a small programm written in C++ using the QT Framework (v. 4.7). The task I want to accomplish is opening an existing xml-document, add a node within its structure and save the document to the file I read it from before. I have tried this using something like that: QFile xmlIn(AFileName); QDomDocument do...

Checking whether a number is positive or negative using bitwise operators

I can check whether a number is odd/even using bitwise operators. Can I check whether a number is positive/zero/negative without using any conditional statements/operators like if/ternary etc. Can the same be done using bitwise operators and some trick in C or in C++? ...

Why is this vector iterator not incrementable?

i'm trying to delete the vector's content and i'm getting an error - vector iterator is not incrementable, why is that? this is my destructor City::~City() { vector <Base*>::iterator deleteIterator; for (deleteIterator = m_basesVector.begin() ; deleteIterator != m_basesVector.end() ; deleteIterator++) m_basesVector....

Problem with % n *** %n in writable segment detected *** C++ i Qt

Problem with % n * %n in writable segment detected * C++ i Qt I have program that process big data, that can't be modified. In one file we encounter "100% na" and application stop. When I checked it with debuger, it return * %n in writable segment detected *. I can't change visible that data, user must see "100% na". I thought of in...

Deprecated conversion from string const. to wchar_t*

Hello I have a pump class that requires using a member variable that is a pointer to a wchar_t array containing the port address ie: "com9". The problem is that when I initialise this variable in the constructor my compiler flags up a depreciated conversion warning. pump::pump(){ this->portNumber = L"com9";} This works fine but th...

Is there an equivalent for __if_exists in gnu c++ ?

__if_exists is a microsoft specific keyword for testing existence of identifiers at compile time: msdn:__if_exists It can come in very handy at "faked" template specialization as in some cases it provides a really much more simple, readable and better performing way than other methods like "real" specialization or overloading or whatev...

Parallel inheritance trees, where classes from one tree have containers of classes from another

I really didn't know how to specify the problem in the title, so here's the gist of it. I am writing graph classes Graph, Node, and Edge, and then subclassing them into VisGraph, VisNode and VisEdge to obtain a drawable graph (in C++). I then need to further subclass those into specific classes that depend on certain data. So I have a l...

How to programmatically load a Java card applet ( a .cap file ) using Visual C++/PCSC

Hi, I am currentlly on a project that requires me to load a JavaCard application Applet ( a .cap ) file to a JavaCard. Our framework is based on Visual C++ and PCSC, so we need to load the same applet to a series of JavaCards. Does anyone know how this can be processed? I mean, where should I start. Thanks! ...

cin.get() in while loop not getting clear idea

in loop there is a cout statement which prints the character which provide from keyboard but inside loop it is not showing it even keep on typing keys from keyboard but when we press enter it shows all of them all together why there is cin.get() outside loop and how does the cin.get() inside the loop behave actually kindly reply thankx...

Fast Algorithm for computing percentiles to remove outliers

I have a program that needs to repeatedly compute the approximate percentile (order statistic) of a dataset in order to remove outliers before further processing. I'm currently doing so by sorting the array of values and picking the appropriate element; this is doable, but it's a noticable blip on the profiles despite being a fairly min...

How to compile c++ in xCode for your IPhone app?

Hi, I am doing my first steps in IPhone developing. I want to use some c\c++ code but I can't find any reference of how it's done (will very appriciate if you can also refer me to your source when you give an answear) I have a file called calc.h containing a "calculator" class with simple add and mult functions, I imported it exactly a...

Need help with logic on how to assign the correct value to a textbox

I am passing in a value to the form that I ultimately assign to a textbox using javascript. The value is a calculation based on values from another page/form. However, the textbox is editable. When reloading the form with the previously saved data, I don't want the value of the textbox to be overwritten with the pre-calculated value ...

Generate UML class diagrams from C++ source files?

With doxygen I can generate nice diagrams but doxygen lacks a deeper analysis of the relationships between classes. It recognizes derivation but other relations are not understood by the tool. Which better utilities are there (commercial or not) that generate more complete UML class diagrams out of C++ source files? PS: The tools availa...

memoryleak detection

hey i am trying to detect leaks in visual studio using : #define _CRTDBG_MAPALLOC #include <stdlib.h> #include <crtdbg.h> and in the end of the main i am typing : _CrtDumpMemoryLeaks(); when i do all of this i am getting the the memoryleaks (what inside them) but not the places that the allocates were made , can u please help me w...

Visual C++ won't create the dll file and stops at the *.lib

I inherited a dll project (Visual C++ 2002) and I'm having a lot of trouble to compile it. Even though the *.def file is in the current dir, VC will only create a lib file, instead of the dll. Anybody knows what might be going on? ...

Compiler Optimization with Parameters

Lets say you have some functions in some classes are called together like this myclass::render(int offset_x, int offset_y) { otherClass.render(offset_x, offset_y) } This pattern will repeat for a while possibly through 10+ classes, so my question is: Are modern C++ compilers smart enough to recognise that wherever the program sto...

Interesting C++ code snippet, any explanations?

Possible Duplicate: Why am I able to make a function call using an invalid class pointer class B { public: int i; B():i(0){} void func1() { cout<<“func1::B\n”; } void func2() { cout<<“i = “<<i; } }; int main() { B *bp = new B; bp->func1(); delete bp; b...

Deploying application question (C++)

Hello! Does someone know if there is a way to pack everything-application related into one (single) exe-file? My product is fully written in C++, has a lot of external plugins (dll) and some external data packages. It should be accessible using the network and without installation (launch in one click). Are there some tools to make ...

What is the equivalent C# code for this Canon SDK C++ code snippet?

What is the C# equivalent of this C++ code? private: static EdsError EDSCALLBACK ProgressFunc ( EdsUInt32 inPercent, EdsVoid * inContext, EdsBool * outCancel ) { Command *command = (Command *)inContext; CameraEve...