void pointers are more or less meant for raw byte allocations. If you wanna use temp, you need it to point to a real type. Keep in, void pointers are allowed but there's no such thing as a void value in C++. So your code should be,

Hence MutantJohn suggested that you create an object of the class type, but it looks like you then forgot to adjust the corresponding code, e.g., from temp->sin to temp.sin. Then you tried creating a pointer to an object of the class type, but of course that is insufficient since you do need a copy of the current object, not merely a pointer.

Generally, if you are implementing the postfix version of operator++ for some type T such that it has the usual semantics, you can simplify by implementing it in terms of its prefix operator++, i.e.,

Code:

T T::operator++(int x)
{
T temp(*this);
++*this;
return temp;
}

Last edited by laserlight; 04-20-2017 at 06:18 PM.

Originally Posted by Bjarne Stroustrup (2000-10-14)

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.