c++

static allocated data structures

I'm working on a existing embedded system (memory is limited, Flash is limited, ...) with an RT OS. All data structures have a fixed size and are allocated at "compile time" and are therefore suited for RT. There is no dynamic memory allocation. The programming language is C++, but there is no STL available. I like to replace some of the...

Why does Process.waitFor() never return?

I am launching a windows process (wrote in C++ but I don't have sources) from Java code in the following way: Process p1 = Runtime.getRuntime().exec(cmdAndParams); p1.waitFor(); My problem is that the waitFor() method never ends. Thus I tried to launch the process in a simple shell and it ends correctly with many print in the shell ...

How to retrieve value type from iterator in C++?

Hi everyone, my question is sure a simple one for anybody familiar with C++ syntax. I'm just learning c++ and this is some sort of homework. template<typename Iter> void quickSort(Iter begin, Iter end) { //.. auto pivot = * ( begin + (end - begin)/2 ); //.. } pivot is supposed to contain value from the center of [b...

Syntax for C# Array[] in C++/CLI

I have an interface defined in C# which has a method Array[] Foo(); I need to implement this interface in a class written in C++/CLI. i tried the following syntax array<array<Object^>^>^ Foo(); But i get an error stating my return type does not match the one in the interface. Does anyone know how to translate a C# Array[] to C++/CL...

simple C++ project samples

Hi there Im trying to learn OOP but I need to see some real case scenarios of using C++. For me, as a beginner in programming internet is too big and the book is too few examples. All I find on the source repositories are large projects or too few details. Can you give me a link to some c++ projects which are good for beginners? It wil...

Put breakpoint on named function

Is there a way to put a breakpoint on any function in Visual Studio, sort of like bm kernel32!LoadLib* in WinDbg? I know one way is to break at application start, find the required DLL load address, then add offset to required function you can get via Depends, and create a breakpoint on address. But that's really slow, and switching to ...

Should I declare these methods const?

I'm working on some C++ code where I have several manager objects with private methods such as void NotifyFooUpdated(); which call the OnFooUpdated() method on the listeners of this object. Note that they don't modify the state of this object, so they could technically be made const methods, even though they typically modify the stat...

Interface-based programming in C++ in combination with iterators. How too keep this simple?

In my developments I am slowly moving from an object-oriented approach to interface-based-programming approach. More precisely: in the past I was already satisfied if I could group logic in a class now I tend to put more logic behind an interface and let a factory create the implementation A simple example clarifies this. In the pa...

objective-c++ how to add method into c++ class

Hi all! i'd like to have a function in api style. But implementation must be on Objective-C lang. So i've read some information and decided to do following - to mix objective-C with C++. And have problem to call an objC method in C++ class. Thats my example: //MYClass.h : class CClass { private: id fileName; BOOL rez; public: bool ...

Turing machine: But why use template metaprogramming ?

Hi there. I am a final year engineering student. Me and my friends have decided that our final year project would be "Simulation of Turing Machine using Template Metaprogramming". I understand what "Turing Machine" and "Template Metaprogramming" are but my question is why the simulation would be tedious if we design the Turing Machine ...

C++ how to check if folder is empty / list existing files

Possible Duplicate: How do you iterate through every file/directory recursively in standard C++ Hello everyone! I've been looking for a way to check if a determined folder is empty or not, and if it isn't, list the existing files in the folder, but of course to no avail. I've been looking around and found something called di...

Fast Updating of QPixmap from byte array

I'm working on a vision application and I need to have a "Live View" from the camera displayed on the screen using a QPixmap object. We will be updating the screen at 30frames/second on a continuous basis. My problem is that this application has to run on some 3-5 year old computers that, by todays standards, are slow. So what I would...

C++ beginner question

I am in the process of learning C++ in order to understand some open source code I have been given. I came across a line as follows: cmd << '\n' I assumed that "cmd" must be some kind of special receptor for a stream, perhaps a string - but on further investigation I found that "cmd" was an entire class with assorted data and functio...

How to listen to COM events from Office applications that were started independently?

What I want to do: Write an application that listens to Office events. I want to listen to events from any instance opened on the machine. E.g. if I'm listening to BeforeDocumentSave in Word, then I want my sink for this method to be activated whenever any instance of Word on the host saves a document. Another requirement is that I'm...

Should C++ keep variables intact on input failure?

Doesn't C++ offer any guarantee about keeping variables intact on input failure? With older versions of gcc, a program like this one keeps the -1 value of i on failure (for instance if a letter is typed instead of a number on input). With Ubuntu 10.10 (gcc 4.4.5), i is reset to zero in case of input failure. #include <iostream> int mai...

Is there a standard way of representing an SHA1 hash as a C string, and how do I convert to it?

This question is about how to create an SHA-1 hash from an array of data in C using the OpenSSL library. It returns an array of 20 bytes, containing the hash. Is there some standard way of representing that data in string form, not binary? If so, is there a function in OpenSSL itself to convert to said string format? If not, how shoul...

array of objects,c++

i have two classes namely Flight and Runway. Now i am trying to pass an array of these objects as parameter to a function. void fun(Flight ptr1[],Runway ptr2[]) { ... ... } ptr1 should point to an array of Flight objects and ptr2 should point to an array of Runway objects. Now inside this function fun() how do i access members of the...

Derived class stored in ptr_vector not being destructed

Was trying to find the best way to use ptr_vector to store, access and release objects, especially when the stored object is inherited from other (ptr_vector should not have any issues with object slicing). But when running the below program, surprisingly the derived class isn't being destructed. Anyone know why? #include <boost/ptr_con...

Is rebasing DLLs (or providing an appropriate default load address) worth the trouble?

Rebasing a DLL means to fix up the DLL such, that it's preferred load adress is the load address that the Loader is actually able to load the DLL at. This can either be achieved by a tool such as Rebase.exe or by specifying default load addresses for all your (own) dlls so that they "fit" in your executable process. The whole point of ...

Inherit class with template function

I would like to create a base class that will be inherited by other objects so that they can be stored in the same container. This base class will contain a templated method that defines the fuction as a setter or getter used for accessing a buffer in a multithreaded system. I want to do something like this guy did but not really sure ...