/*
*Daniel Tabuenca
*###-##-3128
*Login: dtabuenc
*Lab section 23
*Assignment 1
*Due April 28, Friday, 11:59pm, 2000
*/
#include <iostream.h>
#include <fstream.h>
#include "polynomial.h"
int main(int argc, char **argv)
{
/*Check if called with correct arguments*/
if(argc!=2)
{
cout << "Usage: " << *argv << " FILENAME\n";
return(-1);
}
ifstream inFile;
inFile.open(argv[1], ios::nocreate|ios::in);
if (!inFile)
{
cerr << "Error opening file \""<<argv[1]<<"\"\n";
exit(-1);
}
/*Declare Two Polynomials*/
Polynomial poly1,poly2;
/*Read each polynomial from the file*/
inFile >> poly1;
inFile >> poly2;
/*Add the two*/
Polynomial *poly3 = poly1+poly2;
/*Output Result*/
cout << poly1 << " + " << poly2 << " = " << *poly3 << endl;
/*Free the memory*/
delete poly3;
/*Multiply the two*/
poly3=poly1*poly2;
/*Print results*/
cout << poly1 << " * " << poly2 << " = " << *poly3 <<endl;
/*Free memory*/
delete poly3;
}
syntax highlighted by Code2HTML, v. 0.8.11