Hey guys, I'm having a little bit of trouble with a register I'm making. I'm having an error in the build. Also as I'm very new to c++ if you see anything that I can improve on, such as syntax, etc. please tell me as I wish to form good habits. btw, I'm using code blocks if it makes any difference.
Heres head.hpp
sourceCode:#include <iostream> class My_reg { public: My_reg(float amount); //enters amount ~My_reg(); void set_tax(); // declares tax func void start_up() const {sub = amount;} float sub_total() const {return sub;} // returns sub_total amount float get_total() const {return sub;} // return sub after tax float get_change(float cash); // declares func to get change private: float sub; float tax; float cash; float change; };
Thank you for any help && || tips.Code:#include "head.hpp" My_reg::My_reg(float amount) { sub = amount; float tax = 0.05; } My_reg:: ~My_reg() { } void My_reg:: set_tax() { sub = sub + sub * tax; //adds tax } float My_reg:: get_change(float cash) { change = (cash - sub); /// This is supposed to take how much they gave return change; // and subtract from sub, this is after sub has been through set_tax } int main() { std::cout << "Please enter the amount:"; std::cin >> amount; My_reg reg(amount); start_up(); std::cout << "Your sub-total is:" << reg.sub_total(); reg.set_tax(); std::cout << "/nYour total is:" << reg.get_total(); std::cout << "/n Please enter the amount paid:"; std::cin >> cash; std::cout << "Your change is:" << reg.get_change(); std::cout << "/n/tThank you and have a wonderful day"; return 0; }
Joe



LinkBack URL
About LinkBacks




