Help passing a reference to a pointer several times

J

jblau

I am trying to pass a reference through a couple of layers of
functions, and I am getting a C2664 Error.

Here is my setup:

I have a class [ c_ClassOne ] which contains a pointer to an object [
p_MyObject ].

I have a second class [ c_ClassTwo ] which has a function [
FunctionOne(MYOBJECTTYPE* myObject) ]


I have a third class [ c_ClassThree ] which also has a function [
FunctionTwo(MYOBJECTTYPE* myObject) ]


I then try to pass the reference to the pointer p_MyObject from
c_ClassOne to be used within FunctionTwo.

So in a function within c_ClassOne I create an instance of c_ClassTwo [
myClassTwo ]
I then pass a reference to p_MyObject as follows:
myClassTwo.FunctionOne(&p_MyObject);

Then within FunctionOne, I create an Instance of c_ClassThree [
myClassThree ]
I then attempt to once again pass the reference to p_MyObject:
myClassThree.FunctionTwo(&p_MyObject);

On that line I get the following error:
error C2664: 'CD3DInitialize::Enumerate' : cannot convert parameter 1
from 'LPDIRECT3D9 ** ' to 'LPDIRECT3D9'

Note: LPDIRECT3D9 is the Object Type of p_MyObject.


Can anyone explain what I am doing wrong, and help me understand how to
do it correctly?

Thanks,

Jody
 
A

Andre Kostur

I am trying to pass a reference through a couple of layers of
functions, and I am getting a C2664 Error.

Here is my setup:

[snip words...]

Can anyone explain what I am doing wrong, and help me understand how to
do it correctly?

Too many words... not enough code. Provide a compilable and minimal piece
of example code which shows your problem. Based on what you seem to have
described, you're not using C++ terminology correctly... you seem to be
freely swapping between "reference" and "pointer". They're not the same
thing. And you don't appear to be following your own coding standards.
 
I

Ian Collins

jblau said:
I am trying to pass a reference through a couple of layers of
functions, and I am getting a C2664 Error.

Here is my setup:

I have a class [ c_ClassOne ] which contains a pointer to an object [
p_MyObject ].

I have a second class [ c_ClassTwo ] which has a function [
FunctionOne(MYOBJECTTYPE* myObject) ]


I have a third class [ c_ClassThree ] which also has a function [
FunctionTwo(MYOBJECTTYPE* myObject) ]


I then try to pass the reference to the pointer p_MyObject from
c_ClassOne to be used within FunctionTwo.

So in a function within c_ClassOne I create an instance of c_ClassTwo [
myClassTwo ]
I then pass a reference to p_MyObject as follows:
myClassTwo.FunctionOne(&p_MyObject);
You are not, you are passing the address of the pointer. Just pass it
on through if all of your functions take a MYOBJECTTYPE*.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top