Operating Overloading with Pointer Arguments
I am trying to implement a class x that has an overloaded operator(). This overloaded operator needs to have pointer arguments. Can this be done? Here is my code so far.
Code:
class X {
friend ostream& operator <<(ostream &out, const X *ptr)
{
out << ptr->l << " " << ptr->n;
return out;
}
friend bool operator<(const X *ptr1, const X *ptr2)
{
return ptr1->n > ptr2->n;
}
.....
public:
....
private:
char l;
int n;
....
The reason why I want to do this is because I call pointers of type X and they are pointing to some value. I need these values to sort my container. I know its a little vague but it would help me out a lot... if you have any questions about the requirements please do not hesitate to ask. Thanks.