Question: I need to create a makefile for a C++ program. it contains two programs provided in class as listed below. it will also contain two
I need to create a makefile for a C++ program. it contains two programs provided in class as listed below.
it will also contain two other files. a header file, fraction.h and fraction.cpp which is a class file. that will overide several functions to allow fraction cpp to add the fractions. Can someone write a basic makefile for me?
// // useFraction.cpp // // DO NOT MODIFY THIS FILE // #include "Fraction.h" #includeusing namespace std; void print_fraction(const Fraction& f) { cout << "print_fraction: " << f.getNum() << "/" << f.getDen() << endl; } int main() { Fraction x(2,3); Fraction y(6,-2); cout << x << endl; cout << y << endl; cin >> y; cout << y << endl; print_fraction(y); Fraction z = x + y; cout << x << " + " << y << " = " << z << endl; }
// calculator.cpp #include "Fraction.h" #include#include using namespace std; int main() { Fraction x,y; char op; try { cin >> x; cin >> op; while ( cin && ( op == '+' || op == '-' ) ) { cin >> y; if ( op == '+' ) x = x + y; else x = x - y; cin >> op; } cout << x << endl; } catch ( invalid_argument& e ) { cout << "Error: " << e.what() << endl; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
