expression must have a pointer-to-member type

I created a class called Polynomial that asks the user for coefficients and exponent. I also created a function that would add the two polynomials.
I'm stuck on how to access my pointer arrays from an instance and different objects.
I dont understand why i get an error at temp.*(p+i) and op.*(p + i) "expression must have a pointer-to-member type". Please help!

1
2
3
4
5
6
7
8
9
Polynomial Polynomial::operator+(Polynomial op) 
{
	Polynomial temp;
	for(int i = 0; i < SIZE; i++)
	{
		temp.*(p+i) =  *(p + i) + op.*(p + i); //stuck here
        }
	return temp;
}


If additional code is needed, I would be happy to provide them.
*(temp.p + i) = *(p + i) + *(op.p + i);

Or I suppose you could just do
temp.p[i] = p[i] + op.p[i];.
That works... But I was wondering how it would work if I were to use pointers rather instead.
The first line of code that he posted does that?
The first line of code that he posted does that?


So does the second.
Topic archived. No new replies allowed.