Учитывая приведенный ниже пример кода, как функции здесь работают без передачи каких-либо параметров в них?
ПРИМЕЧАНИЕ. Этот пример работает, как ожидалось
#include <iostream>
using namespace std;
class Cuzmo
{
private:
int array[10] = { 95, 45, 48, 98, 485, 65, 54, 478, 1, 2325 };
int n;
public:
Cuzmo ()
{
array[10];
n = sizeof (array) / sizeof (array[0]);
}
void printArray ()
{
for (int i = 0; i < n; ++i)
cout << array[i] << endl;
}
void bubbleSort ()
{
bool swapped = true;
int j = 0;
int temp;
while (swapped)
{
swapped = false;
j++;
for (int i = 0; i < n - j; ++i)
{
if (array[i] > array[i + 1])
{
temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
swapped = true;
}
}
}
}
};
int main ()
{
Cuzmo sort;
cout << "Before Bubble Sort :" << endl;
sort.printArray ();
cout << endl;
sort.bubbleSort ();
cout << "After Bubble Sort :" << endl;
sort.printArray ();
cout << endl;
return (0);
}