More of a namespace problem now, I guess.
I've defined a class named Character, and I have another class called Skill. In one method of class skill, I want to pass two Character pointers to a method called Effect1. I tried doing it the same way as I might with a String pointer:
void effect1(Character*);
I have included the header that defines the Character class in the Skill header, but it keeps giving me the error that Identifier Character could not be found. I'm using Visual C++ .net.
[Edited by - Makkedah on March 22, 2006 10:10:55 AM]
post your code
but this framework will work:
Character.h
Skill.h
Skill.cpp
but this framework will work:
Character.h
#ifndef _CHARACTER_CLASS__#define _CHARACTER_CLASS__class Character{};#endif //_CHARACTER_CLASS__
Skill.h
#ifndef _SKILL_CLASS__#define _SKILL_CLASS__//forward decleration of Character classclass Character;class Skill{ void effect1( Character* );};#endif //_SKILL_CLASS__
Skill.cpp
#include "Skill.h"#include "Character.h"void Skill::effect1( Character* ){ //do whatever}
I don't really know how much to post...
#pragma once
#using <mscorlib.dll>
#include "Gengame1point2.h"//Header in which the Character class is defined.
using namespace System;
namespace skillspace
{
[Serializable]
public __gc class Skill
{
public:
static void effect1(Character*);
}
}
in the Skill function definition file:
void Skill::effect1(Character* opponent)
{
}
And the character class:
#pragma once
#using <mscorlib.dll>
using namespace skillspace;
using namespace itemspace;
using namespace System;
namespace gengame
{
__gc class Character
{
//class members here
};
}
#pragma once
#using <mscorlib.dll>
#include "Gengame1point2.h"//Header in which the Character class is defined.
using namespace System;
namespace skillspace
{
[Serializable]
public __gc class Skill
{
public:
static void effect1(Character*);
}
}
in the Skill function definition file:
void Skill::effect1(Character* opponent)
{
}
And the character class:
#pragma once
#using <mscorlib.dll>
using namespace skillspace;
using namespace itemspace;
using namespace System;
namespace gengame
{
__gc class Character
{
//class members here
};
}
it's because Character is in the gengame namespace so the method needs to actually look like:
-me
//..snipstatic void effect1(gengame::Character*);//..snip
-me
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement