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 45 46 47 48 49 50 51 52 53 54 55
|
template<int arraySize>
class abList{
private:
int count;
//constructor
fullContact infoArray[arraySize];
public:
void arrayConstructor(int size){
arraySize = size;
};
void sort();
void insertContact(int pos, string item);
string removeContact(int pos);
string retrieve(int pos);
int search(string query);
};
int main(int argc, char* argv[])
{
bool isAB = true;
if (argv[2] == NULL)
{
isAB = false;
}
if (isAB)
{
//argv[2] is now size
int size = atoi(argv[2]);
cout << "Creating an array based list of size: " << size << endl;
}
ifstream contactFile(argv[1]);
//if the file is found, open it and import the data into a list
if (contactFile.is_open())
{
string currentLine;
while ( getline (contactFile,currentLine) )
{
stringstream lineStream(currentLine);
fullContact r;
getline(lineStream, r.lastName , ',');
getline(lineStream, r.firstName , ',');
getline(lineStream, r.phoneNumber , ',');
getline(lineStream, r.emailAddress , ',');
cout << r.lastName << endl;
//add to array based list
if (isAB)
{
cout << "Adding contact to ablist!" << endl;
//will insert contact here
}
|