Jump to content
  • Advertisement
Sign in to follow this  
Drunken_Monkey

Where Did I go wrong? (C++)

This topic is 4461 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

#ifndef baseSpell_h
#define baseSpell_h

#include <iostream>
#include "class basePlayer.h"

using namespace std;

class baseSpell
{
public:
	//Constructor
	baseSpell(basePlayer);//error C2460: 'baseSpell::basePlayer' : uses 'baseSpell', which is being defined
	virtual void cast(basePlayer*);//error C2061: syntax error : identifier 'basePlayer'
	basePlayer* owner;
};

baseSpell::baseSpell(basePlayer* j){owner = j;}

void baseSpell::cast(basePlayer* j){cout << "Error\n";}

#endif
Okay, it gives me like 16 more errors. I've looked over all the other classes I defined in my program but there is nothing wrong with them. Grrr, I've wrestled with these errors for about a week and can't figure it out. *Start tearing out his hair.

Share this post


Link to post
Share on other sites
Advertisement
Hey bud,

#include "class basePlayer.h"

should be:

#include "basePlayer.h"

Hope that helps,

Dave

Share this post


Link to post
Share on other sites
sounds like one of those A contains and uses B and B contains and uses A things... so change that pass by value to a pass by reference and make sure u forward declare things. also, i remember you said your filename was actually 'class baseplayer.h'... i suggest you change that so it doesn't have any spaces. there maybe some conflict in the other header as well... you should post it.


class B {
public :
B(A) {} // error C2460: 'B::A' : uses 'B', which is being defined
virtual void cast(A*) {} // error C2065 'A' : undeclared identifier
A* owner;
};

class A {
public :
A() {}
};


change to


class A;
class B;

class B {
public :
B(A&) {}
virtual void cast(A*) {}
A* owner;
};

class A {
public :
A() {}
};

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks for the replies. I prototyped the classes and it compiled fine.

Share this post


Link to post
Share on other sites
Also, I recommend you not use "cast" as one of your identifiers. That seems bound to cause library (if not syntactic or naming) conflicts at some point.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!