|
First, the definition of known classes is as follows:
class Base {
protected:
int iBody;
public:
virtual void printOn () = 0;
Base (int i = 0): iBody (i) ()
};
class Sub1: public Base {
// ...
public:
void printOn ();
Sub1 (int i, char * s);
};
class Sub2: public Base {
// ...
public:
void printOn ();
Sub2 (int i, short s);
};
Try to complete the definition and implementation code of the classes Sub1 and Sub2, so that they can meet
Requirements for the following procedures and the results of the operations described in the comments:
main ()
{
Sub1 s1 (1000, "This is an object of Sub1");
Sub2 s2 (2000, 10);
s1.printOn ();
// This shows: <1000: This is an object of Sub1>
s2.printOn (); // Now: <10 and 2000>
}
Second, define the class template SortedSet, that is, an ordered collection of elements, the type of the collection elements
The maximum number of sum elements can be determined by the user. Require this type of template to be provided externally
The following three operations:
insert: add a new element to the appropriate position, and guarantee the collection element
Prime values do not repeat;
get: Returns the address of the smallest element larger than the given value. If not, return
Back to 0
del: delete the element equal to the given value, and keep the remaining elements
Orderly. |
|