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

c++ classes pointing to eachother

Started by coorrae Apr 29, 2004 at 2:34 AM 1 replies 700+ views
Original Post
coorrae
coorrae
when it reads class cat, person hasnt been defined yet when it reads class person, cat hasnt been defined yet its a catch 22! what do I do? I prefer one file if it matters Im using msvc++7 class cat { person * owner; } class person { cat * firstcat; }
~signature
Fruny
Fruny
a) You need to declare the class
b) Semicolons are not optional.

class person;

class cat
{
person * owner;
};

class person
{
cat * firstcat;
};
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
coorrae
coorrae
thank you.
~signature

Topic Locked

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

Sign in to reply to this topic.