Skip to main content
gamedev.net
🔒 Locked

2-way interaction between class objects

Started by bergfald 1 reply 200+ views
Original Post
bergfald
bergfald
Hi, I am making an engine where I need interaction beteww to class objects. Let''s say: I got to different classes, (and one instance of each, Object1 = new Class1, end Object2 = new Class2). In Object1 I need to access functions in Object2, and vica versa. Like this (very simplified): Class1{ ... blabla = Object2->GetPos(); } Class2{ .... Object1->AddBullet(pos,velocity); } What is the best way to do this (Get a class-pointer to each other)? Sorry about my poor english (and understanding). Erik
E. Bergfaldhttp://bergfald.stud.hive.no
antuk
antuk
You create another class that accesses functions in both of the two classes and deals with the resulting data.

Ant

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.