John has 200 more socks than Johnny
Answer:
class Example:
def __init__(self, val):
self.val = val
def __gt__(self, other):
return self.val > other.val
def __sub__(self,other):
return abs(len(self.val) - len(other.val))
def main():
obj1 = Example('this is a string')
obj2 = Example('this is another one')
print(obj1 > obj2)
print(obj1 - obj2)
main()
\color{red}\underline{Output:}
A class can be defined<span> using another class as a foundation. In object-oriented programming terminology, one class can </span>inherit<span> fi elds and methods from another. An object that inherits from another is called a subclass, and the object it inherits from is called a superclass. A subclass extends the superclass.</span>
Answer:
public: virtual void print()=0;
Explanation:
An abstract class contains a pure virtual function. Pure virtual class cannot be instantiated but it can be subclassed and the subclass can provide an implementation of the function.
A virtual function declaration in the class is preceded by the virtual keyword. For example, virtual void print();
A pure virtual function declaration is followed by '=0;'
public: virtual void print()=0;