4-1
Define and implement a class named sort_by_animalID that has asingle public static function but no constructors:
static void sort(animal **animals,int n) // sorts the array of n animals into ascending order using their animalIDs
You may use your favourite sorting algorithm.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
animal.h file:
#ifndef ANIMAL_H
#define ANIMAL_H
#include <string>
class animal {
protected:
std::string name ; // the animal’s name
static int count;
int animalID ; // the animal’s unique ID
int volume ; // the volume of the animal’s body
public:
animal();
animal(std::string n, int v) ; // creates an animalwith name n and body volume v.
// animals are allocated
PayPal Gateway not configured
PayPal Gateway not configured