# SDK QuestionVessels of the Same Class Interacting?

#### Mr Martian

##### Orbinaut/Addon dev/Donator
Addon Developer
Donator
Hi All,

Wondering if someone can help me with this. I feel it's a simple and obvious problem I've missed. I am currently developing a vessel class, however when I have two of the same class in one scenario, they "interact" with each other, as in the custom parameters I have defined will overwrite/add/subtract etc. from the other vessel, as if Orbiter can't destinguish between the two.

Does anyone know how to solve this? I thought it may have something to do with whether I place the parameters in "private" or "public" in the header file, but seems not.

Thank you in advance!

#### Urwumpe

##### Not funny anymore
Addon Developer
Donator
You can do that with global variables outside the classes or by static or class variables with the keyword "static". Orbiter is not yet Multithreaded, so there is little danger in that method.

Another option is communicating via clbkGeneric or using custom functions of the class.

#### Mr Martian

##### Orbinaut/Addon dev/Donator
Addon Developer
Donator
You can do that with global variables outside the classes or by static or class variables with the keyword "static". Orbiter is not yet Multithreaded, so there is little danger in that method.

Another option is communicating via clbkGeneric or using custom functions of the class.
Hi Urwumpe,

Thanks for the quick reply, what I am trying to achieve is have the vessels not interact at all with each other (in the same way that multiple delta gliders do not)

Is what you have explained the best way to achieve this? Sorry you'll have to forgive my general lack of experience with C++ but to me what you explained sounds to be for getting the vessels to interact with each other? No?

#### Urwumpe

##### Not funny anymore
Addon Developer
Donator
Hi Urwumpe,

Thanks for the quick reply, what I am trying to achieve is have the vessels not interact at all with each other (in the same way that multiple delta gliders do not)

Is what you have explained the best way to achieve this? Sorry you'll have to forgive my general lack of experience with C++ but to me what you explained sounds to be for getting the vessels to interact with each other? No?

Oh - in that case, just do the opposite what I said.

public, private and protected only control the visibility of the variables of a class, not the scope.

public: Visible to all classes
private: visible only to that class
protected: visible only to that class or subclasses of it.

The scope of a variables controls, how many copies of that variables exist.

global variables outside the class exist once per module/DLL
static variables exist once per class.
variables in a class definition exist once per instance of that class = once per vessel.

So for anything that should NEVER interact with other vessels, the best option is something like that:

Code:
class THENAMEOFMYVESSEL: public VESSEL
{
int anyvariable;
};

In that case, anyvariable will only be visible to that vessel class (its private by default) and exist once per vessel.

#### Mr Martian

##### Orbinaut/Addon dev/Donator
Addon Developer
Donator
Oh - in that case, just do the opposite what I said.

public, private and protected only control the visibility of the variables of a class, not the scope.

public: Visible to all classes
private: visible only to that class
protected: visible only to that class or subclasses of it.
Hi Urwumpe,

Thanks so much for clarifying! I always assumed that was probably the case, but somehow never payed much attention to it... probably not the smartest idea...

As it turns out I was defining all my double values under my constants... outside of the class definition... pretty silly. Moved them all to private like you said and it's perfect.

Thank you for helping me out, I was tearing my hear out!

Replies
32
Views
2K
Replies
1
Views
393
Replies
54
Views
2K
Replies
4
Views
470
Replies
2
Views
604