-
passing a struct!
Heya all, i'm trying to pass a structure through a copy constructor, but the class can not seem to see the structure. any ideas on why?, the structure is global before the class file is called(i know, i know.. bad me for having a global struct)
s_iChrStat <-- character stats
Code:
class CBasePlayer
{
CBasePlayer();
CBasePLayer(s_iChrStat stats);
private:
s_iChrStat s_charstat;
};
the class, i cut out alot of usless garbage, this is basically where my problem is.
Code:
CBasePlayer::CBasePLayer()
{
}
CBasePlayer::CBasePLayer(s_iChrStat stats):
s_charstat(stats)
{
cout << "Base Player copy constuctor..\n";
}
then this is the .cpp file.
-
-
I guess this is an advanced question.
-
Can't it find the global struct decleration or the struct definition? if you can't find the global declared struct look up extrern keyword and use it. If it can't find the struct definition, look over your headerfile includings.
-
can't say as I've ever tried to use a struct with the initializing operator. I would try member by member initialzing within the body of the constructor. If that doesn't work then more code (particualarly code for the struct) will be helpful for further evaluation.
-
thanks guys, i found my problem. It seems i needed to include the file that contained the struct again in the class header file. thanks all!