1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <iostream>
using namespace std;
class Sort3
{
private:
float& first;
float& second;
float& third;
public:
Sort3(float& a, float& b, float& c) : first(a), second(b), third(c)
{
}
void swap(float& x, float& y)
{
float temp;
temp = x;
x = y;
y = temp;
}
void mySort()
{
if (first < second)
swap(first, second);
if (third < second)
swap(second, third);
if (first < third)
swap(first, third);
return;
};
int main()
{
float first, second, third;
cout << "Please enter three integers." << endl;
cin >> first, second, third;
Sort3 obj(first, second, third);
obj.mySort;
cout << first, second, third;
return 0;
}
};
|