473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help passing a reference to a pointer several times

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

Jan 14 '07 #1
2 1319
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.
Jan 14 '07 #2
"jblau" <jo******@gmail.comwrote 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.
Jan 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
11
by: Mannequin* | last post by:
Hi all, I'm working on a quick program to bring the Bible into memory from a text file. Anyway, I have three questions to ask. First, is my implementation of malloc () correct in the program to...
17
by: LP | last post by:
Hello, Here's the scenario: Object A opens a Sql Db connection to execute number of SqlCommands. Then it needs to pass this connection to a constructor of object B which in turn executes more...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
12
by: Mike | last post by:
Consider the following code: """ struct person { char *name; int age; }; typedef struct person* StructType;
11
by: c19h28o2 | last post by:
Hi, Guy's I know there are several posts about this, however I do not want to read them as answers are undoubtedly posted! Here is my attempt but I'm slightly stuck. I'm not looking for the...
8
by: Ivan Liu | last post by:
Hi, I'd like to ask if passing an object as an pointer into a function evokes the copy constructor. Ivan
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
4
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.