Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Help passing a reference to a pointer several times

Reply
Thread Tools

Help passing a reference to a pointer several times

 
 
jblau
Guest
Posts: n/a
 
      01-14-2007
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

 
Reply With Quote
 
 
 
 
Andre Kostur
Guest
Posts: n/a
 
      01-14-2007
"jblau" <> wrote in news:1168756044.456046.154740
@l53g2000cwa.googlegroups.com:

> 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.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      01-14-2007
jblau wrote:
> 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*.

--
Ian Collins.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pointer to pointer or reference to pointer A C++ 7 07-05-2011 07:49 PM
RDOC: several related modules in several C files Victor \Zverok\ Shepelev Ruby 3 03-16-2007 04:15 PM
passing the address of a pointer to a func that doesnt recieve a pointer-to-a-pointer jimjim C Programming 16 03-27-2006 11:03 PM
Please help -- How to run script several times within one document ThunStorm Javascript 0 02-15-2006 03:22 PM
Passing the value by reference is same as pointer by reference sam pal C++ 3 07-16-2003 09:14 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57