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 Dateien\Visual Studio Projects\2DSpielfeld\Direct3D.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
************************************************** ***************************************** 6 2876
"Andreas Schmitt" <Ke**********@gmx.de> schrieb im Newsbeitrag
news:dc*************@news.t-online.com... 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 Dateien\Visual Studio Projects\2DSpielfeld\Direct3D.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.
** 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
************************************************** **************************
***************
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
"Ian" <no***@nowhere.com> schrieb im Newsbeitrag
news:11***************@drone2-svc-skyt.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
Andreas Schmitt wrote: "Ian" <no***@nowhere.com> schrieb im Newsbeitrag news:11***************@drone2-svc-skyt.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 :)
Ian
"Andreas Schmitt" <Ke**********@gmx.de> wrote in message
news:dc*************@news.t-online.com... "Ian" <no***@nowhere.com> schrieb im Newsbeitrag news:11***************@drone2-svc-skyt.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
Eeeek!
You're right of course. Thanks
Will do
"Howard" <al*****@hotmail.com> schrieb im Newsbeitrag
news:nQ*********************@bgtnsc04-news.ops.worldnet.att.net... "Andreas Schmitt" <Ke**********@gmx.de> wrote in message news:dc*************@news.t-online.com... "Ian" <no***@nowhere.com> schrieb im Newsbeitrag news:11***************@drone2-svc-skyt.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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lars Plessmann |
last post by:
Problem: I try to store data in a objects field and read it out again.
Sounds easy, yeah. But its a bit tricky here.... ;-)
This is the class Customer.php with some setter and getter functions...
|
by: Leslaw Bieniasz |
last post by:
Cracow, 20.09.2004
Hello,
I need to implement a library containing a hierarchy of classes
together with some binary operations on objects. To fix attention,
let me assume that it is a...
|
by: Kent Lewandowski |
last post by:
hi all,
Recently I wrote some stored procedures using java jdbc code
(admittedly my first stab) and then tried to implement the same within
java packages (for code reuse). I encountered...
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: ajikoe |
last post by:
Hi,
I tried to follow the example in swig homepage.
I found error which I don't understand.
I use bcc32, I already include directory where my python.h exist in
bcc32.cfg.
/* File : example.c...
|
by: Bryce Calhoun |
last post by:
Hello,
First of all, this is a .NET 1.1 component I'm creating.
SUMMARY
-----------------------
This component that I'm creating is, for all intents and purposes, a
document parser (I'm...
|
by: TPJ |
last post by:
Help me please, because I really don't get it. I think it's some stupid
mistake I make, but I just can't find it. I have been thinking about it
for three days so far and I still haven't found any...
|
by: per9000 |
last post by:
An interesting/annoying problem.
I created a small example to provoke an exception I keep getting.
Basically I have a C-struct (Container) with a function-pointer in it.
I perform repeated calls...
|
by: bizt |
last post by:
Hi,
Below I have a simple object / function thing (still getting head
round these) declaration:
function MyObject() {
this.alertMe = function() {
alert('hello');
};
this.alertMeAgain() {
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |