Skip to main content
GameDev.net gamedev.net
🔒 Locked

some basic help on c++ needed.

Started by zaph Oct 18, 2000 at 10:26 AM 1 replies 150+ views
Original Post
zaph
zaph
heres my problem. Its really basic so please dont take the piss (too much). I''m programming in c++ (djgpp). I''ve got two classes, called ''enemy'' and ''player''. for collision detection reasons, enemy needs to run player functions AND player needs to run enemy functions. This means that both classes need to be defined before the other. Which is impossible. By looking at other peoples'' programs, I gather that it is possible to ''predefine'' a class to solve this problem:- class player{ }; class enemy{ player *p; }; class player{ enemy *e; }; However, if I do this, I get the error message ''re-definition of class player''. How can I solve this problem???? thanks in advance - felix.
Jumpster
Jumpster
class player;

Not: class player {};

That''s all there is to it...





Regards,
Jumpster


Semper Fi
Regards,JumpsterSemper Fi

Topic Locked

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

Sign in to reply to this topic.