home
clear breadcrumbs
search
login
 
overloading
** overloading ** #include
using namespace std; // double finalCost(double, double); // funtion prototype // or // double finalCost(double, double, string); // funtion prototype - optional parameter void finalCost(double, double); void finalCost(double, double, string); const double taxRate{ 0.10 }; void main() { double baseCost{}; cout << "Enter base cost: "; cin >> baseCost; cout << endl; finalCost(baseCost, taxRate); // function call cout << endl; finalCost(baseCost, taxRate, "This is a comment"); // function call cout << endl; } // function definition with overloading void finalCost(double baseCost, double tax, string comment) { cout << baseCost + baseCost * tax << " " << comment; } // function definition void finalCost(double baseCost, double tax) { cout << baseCost + baseCost * tax ; cout << endl; }