Object as Argument?

M

Marek Franke

Hello,

I have written a small program which creates a small object from a class:

---------------
#include "Object.hpp"
Object obj;
obj.init();
std::cout << obj.no << std::endl;
---------------
Result an integer stored in obj.no

Works fine and everything is OK. Now I want to start from this program a
new program with system. And with the systemcall I want to commit the
object from the 1. program to the 2. program:

--------------
// program 1
system("program2 obj");
--------------
// program 2
#include "Object.hpp"
int main(Object obj) {
std::cout << obj.no << std::endl;
}
--------------

Result: anything but not what is declared in Object::init();

How can I solve this? I think I'm on the wrong way, even with this
system("..."). I just want to create an object only one time and commit
this to program2 without creating it a second time. Is this possible in
any way?

Thank, Marek
 
M

mlimber

Marek said:
Hello,

I have written a small program which creates a small object from a class:

---------------
#include "Object.hpp"
Object obj;
obj.init();
std::cout << obj.no << std::endl;
---------------
Result an integer stored in obj.no

Works fine and everything is OK. Now I want to start from this program a
new program with system. And with the systemcall I want to commit the
object from the 1. program to the 2. program:

--------------
// program 1
system("program2 obj");
--------------
// program 2
#include "Object.hpp"
int main(Object obj) {
std::cout << obj.no << std::endl;
}
--------------

Result: anything but not what is declared in Object::init();

How can I solve this? I think I'm on the wrong way, even with this
system("..."). I just want to create an object only one time and commit
this to program2 without creating it a second time. Is this possible in
any way?

Yes, but it's platform dependent. Look up CORBA or COM.

Cheers! --M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,233
Latest member
AlyssaCrai

Latest Threads

Top