More of a namespace problem now, I guess.

Started by
3 comments, last by Makkedah 18 years ago
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]
"Duty is as heavy as a mountain, death is as light as a feather"-Al'' Lan Mandragoran
Advertisement
post your code

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
};
}
"Duty is as heavy as a mountain, death is as light as a feather"-Al'' Lan Mandragoran
it's because Character is in the gengame namespace so the method needs to actually look like:

//..snipstatic void effect1(gengame::Character*);//..snip


-me
Actually, now my error is that the gengame namespace does not exist. I use it in several other files, I don't understand why this one is any different except perhaps because it is in a namespace as well. Any ideas about this?

[Edited by - Makkedah on March 21, 2006 5:47:03 PM]
"Duty is as heavy as a mountain, death is as light as a feather"-Al'' Lan Mandragoran

This topic is closed to new replies.

Advertisement