On Oct 5, 1:31 pm, "C Programmer , MFC" <sathishss...@gmail.com>
wrote:
Hi,
I am Satheesh asking a question
how can i implement a LinkedList (singly/doubly) in a Shared Memory in
C++.
Bcse In interprocess communication 2/more process can share the add/
delete/update the values in the object in the Linkedlist via
pointer's.how can i achieve this.
Plz Give me an example.
Regards
Satheesh.S
Simple data structure that will do that is index-based (not pointer-
based) linked list, e.g:
template <typename YOUR_DATA>
struct Example
{
Example() :Prev(end), next(end) {}
YOUR_DATA Data;
enum { end = -1 };
int Prev;
int Next;};
Example example[ITEM_COUNT];
(I am too lazy to write operations down, but you can probably find
that on the internet. In fact, I'd be surprised that there isn't even
a C++ implementation of the above somewhere already.)
Why do you need indexes? Because pointers are specific to your
process's address space, and are different from one process to
another, hence their inapplicability in an IPC scenario.
That said... Unless this is not for a homework, I would strongly
suggest COM for any inter-process communication under Windows. COM may
seem to be from another world, but (bar learning curve), for anything
"real", it's leaps and bounds better than lower level system
primitives (shared memory, pipes, mailslots etc).
Goran.
Thank you very much for your reply.
And i am using winxp os, unfortunately i forget this to say.
not sure to get this but trying...