Object as Argument?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marek Franke

    #1

    Object as Argument?

    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("program 2 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
  • mlimber

    #2
    Re: Object as Argument?

    Marek Franke wrote:[color=blue]
    > 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("program 2 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?[/color]

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

    Cheers! --M

    Comment

    Working...