Tuesday, 15 September 2015

c++ - Set and get variables among objects without referencing them -



c++ - Set and get variables among objects without referencing them -

i have lot of objects not aware of each other, need exchange info between them (set , get variables of objects). how can that? investigated observer design pattern seems pattern can used when observed info similar between classes.

in other words, done follows:

void objectb::setvara(objecta &objecta) { objecta.setvar(15); }

but without passing &object.

observer design pattern is looking for. can create objects observable, , have observer has command on them. can have different observers different objects :

it seems pattern can used when observed info similar between classes

is misunderstanding. check this , this

you can notify observers according different actions. illustration when obj1's "name" property changes, can notify observer when obj2's "date" property changes can 1 time again notify observer.

c++ oop

No comments:

Post a Comment