Click here to Skip to main content
15,891,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i want to use a method of a class in another class,but i get error below,whats the problem?

TIA

error: no matching function for call to ‘PositionInfo::PositionInfo()’

here is my code:


SQL
PositionInfo Pos;
double metr=Pos.GetBallDistToTeammate(5);///i got the error here


and PositionInfo.h class is:

SQL
PositionInfo(WorldState *pWorldState, InfoState *pInfoState);


and PositionInfo.cpp class is:

C#
const double & GetBallDistToTeammate(Unum unum) const { Assert(unum > 0); return GetBallDistToPlayer(unum); }
Posted
Updated 23-Mar-11 22:05pm
v2

You must either:
  • define the contructor without arguments for the PositionInfo class (i.e. PositionInfo::PositionInfo()).

or
  • Use your already defined contructor in the Pos variable definition (e.g. PositionInfo Pos(NULL, NULL);).
 
Share this answer
 
The class PositionInfo should be like this:
class PositionInfo
{
public:
    PositionInfo() {};   // replace with your constructor

    double GetBallDistToPlayer(Unum unum) const 
    { 
        return X;  // return your value here
    }

    double GetBallDistToTeammate(Unum unum) const
    {
        return GetBallDistToPlayer(unum);
    }
};
 
Share this answer
 
v4
I think that perhaps you need to define a GetBallDistToTeammate function that takes an int, or cast the parameter to a Unum...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900