Sign in to follow this  
dbrayford

type *& to type *

Recommended Posts

I am getting the following error message
"no matching function for call E::computeX( B*&, A&)"

However, I thought I was passing B* and A rather than B*& and A&.

How do I go about converting B*& to B* and A& to A?

Sample header file

class A
{
};

class B
{
};

class C
{
A a;
D * d;
};

Sample implementation file

void C::compute(B b[3], int * i)
{
d->e->computeX(b, a);
}


Where E::computeX(B b[], A a);

Share this post


Link to post
Share on other sites
The following compiles and runs for me on MSCV 2010:

class A
{
};

class B
{
};

struct E {
void computeX(B b[], A a);
};

struct D
{
E *e;
};

struct C
{
A a;
D * d;

void compute(B b[3], int * i);
};

// Sample implementation file

void C::compute(B b[3], int * i)
{
d->e->computeX(b, a);
}


void E::computeX(B b[], A a) {
}

int main()
{
//A a;
B b[3];
C c;
D d;
E e;
d.e = &e;
c.d = &d;

c.compute(b, 0);
}


I'm worried about the number of pointers involved, and the raw array passing without passing the number of elements in the array. Have you considered smart pointers and containers?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this