C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with Calling Methods from Objects which are stored i

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Andreas Schmitt
Guest





PostPosted: Thu Jul 28, 2005 6:15 am    Post subject: Problem with Calling Methods from Objects which are stored i Reply with quote



Ok. I got the following problem. I created the following array and executed
a function :

CField* Spielfeld[20][20];

CreatePlayField( Spielfeld );

*************************************************
******** CreatePlayField looks like this ************
*************************************************

// Set PlayField Coordinates and Size
void CreatePlayField( CField* PlayField[20][20] )
{
for ( int tmpx = 1; tmpx<=20; tmpx++ )
{
for ( int tmpy = 1; tmpy<=20; tmpy++ )
{
PlayField[tmpx][tmpy] = new CField;

PlayField[tmpx][tmpy]->SetXCoord( (tmpx-1)*FLD_WIDTH +
(tmpx*2) );
PlayField[tmpx][tmpy]->SetYCoord( (tmpy-1)*FLD_HEIGHT +
(tmpy*2) );
PlayField[tmpx][tmpy]->SetWidth( FLD_WIDTH );
PlayField[tmpx][tmpy]->SetHeight( FLD_HEIGHT );
}
}
}

**************************************
** Till here all this works
**************************************

**********************************************************************************************
**** Later in the code a function of the CDirect3D-Object 'Direct3D' is
called like this
**********************************************************************************************

Direct3D.Init(hWnd, Spielfeld);

***********************************
**** ...and the problematic part looks like this
***********************************

BOOL CDirect3D::Init(HWND hWnd, CField* PlayField[20][20], BOOL bWindowed)
{
....


for ( int x = 1; x<=20; x++ )
{
for ( int y = 1; y<=20; y++)
{
m_RFieldRect[x][y] = (PlayField[x][y]->GetXCoord,
PlayField[x][y]->GetYCoord,
PlayField[x][y]->GetWidth,
PlayField[x][y]->GetHeight );

m_lpD3DDevice->ColorFill(m_lpD3DSurface,
&m_RFieldRect[x][y],
PlayField[x][y]->GetColor());
}
}


....

}

******************************************************************************************
** Here I get several error messages which say:
**
** g:Eigene DateienVisual Studio Projects2DSpielfeldDirect3D.cpp(80):
error C2475: 'CField::GetXCoord':
** forming a pointer-to-member requires explicit use of the address-of
operator ('&') and a qualified name
**
** The MSDN Help on that error message didn't really help me and I don't
really know what's the problem
** Searching the internet also didn't really help.
** My experience with C++ is probably simply not high enough yet to get
what's the problem here
** Any help would be appreciated
*******************************************************************************************


Back to top
Christian Meier
Guest





PostPosted: Thu Jul 28, 2005 6:32 am    Post subject: Re: Problem with Calling Methods from Objects which are stor Reply with quote




"Andreas Schmitt" <KeldorKatarn (AT) gmx (DOT) de> schrieb im Newsbeitrag
news:dc9t5t$r9k$01$1 (AT) news (DOT) t-online.com...
Quote:
Ok. I got the following problem. I created the following array and
executed
a function :

CField* Spielfeld[20][20];

CreatePlayField( Spielfeld );

*************************************************
******** CreatePlayField looks like this ************
*************************************************

// Set PlayField Coordinates and Size
void CreatePlayField( CField* PlayField[20][20] )
{
for ( int tmpx = 1; tmpx<=20; tmpx++ )
{
for ( int tmpy = 1; tmpy<=20; tmpy++ )
{
PlayField[tmpx][tmpy] = new CField;

PlayField[tmpx][tmpy]->SetXCoord( (tmpx-1)*FLD_WIDTH +
(tmpx*2) );
PlayField[tmpx][tmpy]->SetYCoord( (tmpy-1)*FLD_HEIGHT +
(tmpy*2) );
PlayField[tmpx][tmpy]->SetWidth( FLD_WIDTH );
PlayField[tmpx][tmpy]->SetHeight( FLD_HEIGHT );
}
}
}

**************************************
** Till here all this works
**************************************


****************************************************************************

******************
Quote:
**** Later in the code a function of the CDirect3D-Object 'Direct3D' is
called like this

****************************************************************************

******************
Quote:

Direct3D.Init(hWnd, Spielfeld);

***********************************
**** ...and the problematic part looks like this
***********************************

BOOL CDirect3D::Init(HWND hWnd, CField* PlayField[20][20], BOOL bWindowed)
{
...


for ( int x = 1; x<=20; x++ )
{
for ( int y = 1; y<=20; y++)
{
m_RFieldRect[x][y] = (PlayField[x][y]->GetXCoord,
PlayField[x][y]->GetYCoord,
PlayField[x][y]->GetWidth,

PlayField[x][y]->GetHeight );

m_lpD3DDevice->ColorFill(m_lpD3DSurface,
&m_RFieldRect[x][y],

PlayField[x][y]->GetColor());
}
}


...

}


****************************************************************************

**************
Quote:
** Here I get several error messages which say:
**
** g:Eigene DateienVisual Studio Projects2DSpielfeldDirect3D.cpp(80):
error C2475: 'CField::GetXCoord':


Try 'CField::GetXCoord()' instead of 'CField::GetXCoord'. That's what I can
see so far. If this does not solve the problem, paste the code of the class
CField.


Quote:
** forming a pointer-to-member requires explicit use of the address-of
operator ('&') and a qualified name
**
** The MSDN Help on that error message didn't really help me and I don't
really know what's the problem
** Searching the internet also didn't really help.
** My experience with C++ is probably simply not high enough yet to get
what's the problem here
** Any help would be appreciated

****************************************************************************

***************
Quote:





Back to top
Ian
Guest





PostPosted: Thu Jul 28, 2005 7:14 am    Post subject: Re: Problem with Calling Methods from Objects which are stor Reply with quote



Andreas Schmitt wrote:
Quote:
for ( int x = 1; x<=20; x++ )
{
for ( int y = 1; y<=20; y++)
{
m_RFieldRect[x][y] = (PlayField[x][y]->GetXCoord,

I assume GetXCoord is a function, so you are missing the ().

The compiler is attempting to take the address of GetXCoord.

Ian

Back to top
Andreas Schmitt
Guest





PostPosted: Thu Jul 28, 2005 7:24 am    Post subject: Re: Problem with Calling Methods from Objects which are stor Reply with quote


"Ian" <noone (AT) nowhere (DOT) com> schrieb im Newsbeitrag
news:1122534867.445131 (AT) drone2-svc-skyt (DOT) qsi.net.nz...
Quote:
Andreas Schmitt wrote:
for ( int x = 1; x<=20; x++ )
{
for ( int y = 1; y<=20; y++)
{
m_RFieldRect[x][y] = (PlayField[x][y]->GetXCoord,

I assume GetXCoord is a function, so you are missing the ().

The compiler is attempting to take the address of GetXCoord.

Ian

Duh! I knew it.. it had to be something this simple.. *g*
I guess coding all night long makes you become this blind to seeing stuff
like this

Thanks to both of you for the quick help anyway



Back to top
Ian
Guest





PostPosted: Thu Jul 28, 2005 9:04 am    Post subject: Re: Problem with Calling Methods from Objects which are stor Reply with quote

Andreas Schmitt wrote:
Quote:
"Ian" <noone (AT) nowhere (DOT) com> schrieb im Newsbeitrag
news:1122534867.445131 (AT) drone2-svc-skyt (DOT) qsi.net.nz...

Andreas Schmitt wrote:

for ( int x = 1; x<=20; x++ )
{
for ( int y = 1; y<=20; y++)
{
m_RFieldRect[x][y] = (PlayField[x][y]->GetXCoord,

I assume GetXCoord is a function, so you are missing the ().

The compiler is attempting to take the address of GetXCoord.

Ian


Duh! I knew it.. it had to be something this simple.. *g*
I guess coding all night long makes you become this blind to seeing stuff
like this

Just think how many hidden bugs the all night session has introduced Smile


Ian

Back to top
Howard
Guest





PostPosted: Thu Jul 28, 2005 3:28 pm    Post subject: Re: Problem with Calling Methods from Objects which are stor Reply with quote


"Andreas Schmitt" <KeldorKatarn (AT) gmx (DOT) de> wrote

Quote:

"Ian" <noone (AT) nowhere (DOT) com> schrieb im Newsbeitrag
news:1122534867.445131 (AT) drone2-svc-skyt (DOT) qsi.net.nz...
Andreas Schmitt wrote:
for ( int x = 1; x<=20; x++ )
{
for ( int y = 1; y<=20; y++)
{
m_RFieldRect[x][y] = (PlayField[x][y]->GetXCoord,

I assume GetXCoord is a function, so you are missing the ().

The compiler is attempting to take the address of GetXCoord.

Ian

Duh! I knew it.. it had to be something this simple.. *g*
I guess coding all night long makes you become this blind to seeing stuff
like this

Thanks to both of you for the quick help anyway

Now that you've got it compiling, you might want to stop it from crashing,
also. :-)

You're using indexes from 1 through 20. In C++, arrays are indexed starting
at 0, not 1. Your loops need to start at 0 and only continue while the
index is _less_than_ 20.

-Howard



Quote:




Back to top
Andreas Schmitt
Guest





PostPosted: Fri Jul 29, 2005 3:44 pm    Post subject: Re: Problem with Calling Methods from Objects which are stor Reply with quote

Eeeek!
You're right of course. Thanks
Will do

"Howard" <alicebt (AT) hotmail (DOT) com> schrieb im Newsbeitrag
news:nQ6Ge.502091$cg1.314021 (AT) bgtnsc04-news (DOT) ops.worldnet.att.net...
Quote:

"Andreas Schmitt" <KeldorKatarn (AT) gmx (DOT) de> wrote in message
news:dca18m$1fh$02$1 (AT) news (DOT) t-online.com...

"Ian" <noone (AT) nowhere (DOT) com> schrieb im Newsbeitrag
news:1122534867.445131 (AT) drone2-svc-skyt (DOT) qsi.net.nz...
Andreas Schmitt wrote:
for ( int x = 1; x<=20; x++ )
{
for ( int y = 1; y<=20; y++)
{
m_RFieldRect[x][y] = (PlayField[x][y]->GetXCoord,

I assume GetXCoord is a function, so you are missing the ().

The compiler is attempting to take the address of GetXCoord.

Ian

Duh! I knew it.. it had to be something this simple.. *g*
I guess coding all night long makes you become this blind to seeing stuff
like this

Thanks to both of you for the quick help anyway

Now that you've got it compiling, you might want to stop it from crashing,
also. :-)

You're using indexes from 1 through 20. In C++, arrays are indexed
starting at 0, not 1. Your loops need to start at 0 and only continue
while the index is _less_than_ 20.

-Howard









Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.