Hello, i am writing a program for my data structures corse that sorts some numbers read in from a text file using quick sort. As you might tell i am new to programming (so go easy on the jargon)

I have tried to write and implement parts of source code given to us in examples but obviously incorrectly. The program uses an array with 2 values - the value of the number (other) and the origional position in the text file (key). The two main problems i think i am having is that it says overloaded member function for the sort and the adding in numbers function. (not sure how to get numbers into sort function). The compiler also doesnt like when i try and get or change things in the array
e.g. k = ptable[3].key; wont work. In the examples given to us this is a fine statement so i dont understand why its not ok..

Any help on any of the problems in my code will be greatly appreciated as i am a bit stuck. Thanks alot nick

Code:

#include <iostream.h>  // I/O 
#include <fstream.h>   // file I/O
#include <stdio.h>
#include <conio.h>
#define MAX 1000000     //Defines the max amount of numbers that can be sorted by the algorithm, I have chosen 1000000 because it 
						//is a sensible amount for the memory to handle


struct ipair {
	int key;
	float other;
	};

class table_of_pairs {
	int table_size;
	ipair *ptable;
	int num_in_table;

	
public:
	table_of_pairs(const int size) 	{				
		num_in_table = 0;
		ptable = new ipair[(table_size = size)+1];		// Set up an array of the requested size
														
		};

	~table_of_pairs() 		{delete [] ptable;};
	int add_to_table(ifstream);
	int quick_sort();
	};


void table_of_pairs::add_to_table()
	{
	int i;
	char others[40];

	ifstream fp_in("numbers.txt", ios::in);  // declare and open file numbers.txt

	while(others != 0)
		{
		for(i=0; i<MAX; i++)
			{
			cin >> others;
			ptable[i].key = i;
			ptable[i].other = others;
			} 
		}
		fp_in.close();   // close the streams
	}









int table_of_pairs::quick_sort(float darr[MAX], int lb, int ub)
	{
	
	float a;
	int up, down;
	float temp;           /* temporary variable, used in swapping */

	if (lb >= ub)
		return;

	a = darr[lb].other;
	up = ub;
	down = lb;

	while (down < up)
	{
	 while (darr[down].other <= a)         /* scan the keys from left to right */
		    down++;
		while (darr[up].other > a)             /* scan the keys from right to left */
		 up--;
	    if (down < up)
		{
		    temp = darr[down].other;          /* interchange records */
			darr[down].other = darr[up].other;
			darr[up].other = temp;
		}
	}

	darr[lb].other = darr[up].other;                /* interchange records */
	darr[up].other = a;

	quick_sort(darr, lb, up-1);         /* recursive call - sort first subtable */
	quick_sort(darr, up+1, ub);         /* recursive call - sort second subtable */
	}

void main()
	{
	int key, mid, mi, md, firstkey, lastkey, size;
	float n, median, first, last;
	table_of_pairs mytable(MAX); 
	
	mytable.add_to_table(size);
	size = sizeof(ptable)/sizeof(ptable[0]);
	//size = table_size;
	int lb = 0, ub;						/* upper and lower bound variables */
	ub = size;
	mytable.quick_sort(ptable, ub,lb);
	
	if(size%2==0)

	{
		n = size/2;
		mid = n;
		mi = n+1;
		md = (ptable[mid].other + ptable[mi].other)/2;
		key = ptable[md].key;
		median = ptable[md].other;
		cout << "The median value is" << median << "at line" << key;
		cout << "\n";

	}

	else
	n = (size/2) + 0.5;
	median = ptable[n].other;
	key = ptable[n].key;

	cout << "The median value is" << median << "at line" << key;
	cout << "\n";

	first = ptable[0].other;
	firstkey = ptable[0].key;

	last = ptable[size - 1].other;	
	lastkey = ptable[size - 1].key;
	cout << "The first value is" << first << "at line" << firstkey;
	cout << "\n";
	cout << "The last value is" << last << "at line" << lastkey;
	cout << "\n";


	}