Sign in to follow this  

Header Error

This topic is 4307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm not surprised. Are you trying to forward declare a class? A variable? A class contained within another class? Something else?

Σnigma

Share this post


Link to post
Share on other sites
try:
extern beast GreenSlime;
in your header file with
beast GreenSlime;
in your cpp file. The "extern beast GreenSlime;" is the declaration of your variable (GreenSlime) and that declaration will be visible to all of the files that include the header file. The "beast GreenSlime;" in your cpp file should only be compiled once. The linking step of building will take care of making sure all of your files are using the same object.

Share this post


Link to post
Share on other sites
Okay I did so and it works. I get a different error later in the compile though:

[Linker error]undefined reference to 'GreenSlime'

It was repeated several times to; and I think it was refering to the following code:

if(enemy = 1)
{
Ehp = GreenSlime.Hp;
Edmg = GreenSlime.Dmg;
Edef = GreenSlime.Def;
Eexp = GreenSlime.Exp;
Ecoin = GreenSlime.Coin;
Ename = GreenSlime.Name;
}

Share this post


Link to post
Share on other sites
Quote:
Original post by Servant of the Lord
if(enemy = 1)

Just spotted that. I assume you meant if (enemy == 1). Assuming this is an error in your source and not a forum transcription error your compiler should have warned you about an assignment in a conditional. Listen to it. If it's not issuing a warning then find the compiler option that will make it.

Σnigma

Share this post


Link to post
Share on other sites
Quote:
Original post by Enigma
Quote:
Original post by Servant of the Lord
if(enemy = 1)

Just spotted that. I assume you meant if (enemy == 1). Assuming this is an error in your source and not a forum transcription error your compiler should have warned you about an assignment in a conditional. Listen to it. If it's not issuing a warning then find the compiler option that will make it.

Σnigma


Whoops, I do mean '=='. I wonder why my compiler missed that? I wonder how I missed that?

Share this post


Link to post
Share on other sites

This topic is 4307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this