Archived

This forum has been archived. Please start a new discussion on GitHub.

Class definition and visibility in c++

Hi all!!

I have the following problem.
I define a class in my Example.ice file. This class is named Cstate and has some variables (int).
In my next code, I import the Example.h in a MyProgram.h and define an instance of CstatePtr mycstate. In MyProgram.h I also defined two functions: function1() and function2() (I don't have constructor, I use the default one)
In MyProgram.cpp I implement function1() with some code, and also I start the pointer Cstate with that instruction:


mycstate = new CState();

I use successfully my variable mycstate , changing some of its int values.

I always call function1() before function2().
But my problem comes when I try to access mycstate from function2().
Note: I invoke function2 remotely throw a TopicManager.

and I get this error:

/MyProgram: warning: dispatch exception: /usr/include/IceUtil/Handle.h:39: IceUtil::NullHandleException
identity: EB32EC5E-ABF4-4AC8-8847-5926997ECB31
facet:
operation: function2

Some comments:
The problem , I think comes from C++ visibility of variables, but I am sure any definition of pointer variables should be done at this way ( in the .h)
Trying to debug the problem, I got the value of mycstate when function2 calls it , and it was 0 (null) , so it doesn't get the same mycstate that function1 uses , because I created it before , so it got a different value than 0.


can anyone help me?
thanks in advanced!

Comments

  • Can you put together a small, self-contained example that demonstrates the problem? It's difficult to say what is going on without seeing the code.

    Thanks,

    Michi.