I can write
friend bool operator<(const Integer& left, const Integer& right);
but i cannot use
virtual bool operator<(const Integer& left, const Integer& right);
or
bool operator<(const Integer& left, const Integer& right);
no.cpp:10: error: bool Integer::operator<(const Integer&, const
Integer&) must take exactly one argument
1. why this error does not occur while use "friend" prefix?
2. and how to create "virtual bool operator<" ?
in code :
---------------------------------------------------------------
#include <iostream>
using namespace std;
class Integer{
friend bool
operator<(const Integer& left,
const Integer& right);
virtual bool
operator>(const Integer& left,
const Integer& right);
};
main(){}
---------------------------------------------------------------
i need the virtual function and then inherit its class, overload
operator< (not virtual) and use polimorphism call function.