• Advertisement
Sign in to follow this  

type *& to type *

This topic is 2600 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement