Reputation: 11
I'm having trouble passing a reference variable in a c++/cli managed class! Its obvious how to do it in an unmanaged class but i'm working with c++/cli :/
Here is an example of what i'm trying to do:
pManager->checkBoundary( int^ mX, int^ mY - 1 );
void Manager::checkBoundary( int^ cX, int^ cY )
{
if( cY >= 0 )
{
cY = this->mBoardHeight;
}
else if( cY < mBoardHeight )
{
cY = 0;
}
else if( cX >= 0 )
{
cX = this->mBoardWidth;
}
else if( cX < mBoardWidth )
{
cX = 0;
}
}
I know this is incorrect but how do i pass a reference var??
Upvotes: 0
Views: 3495
Reputation: 31657
Use the same as you would in an unmanaged class: void Manager::checkBoundary(int& cX, int& cY);
. If this does not work: how do you allocate the integers that you pass?
Upvotes: 1