I have a problem where I have to create a class called Employee and calculate things such as pay etc..Part of the problem is to override the stream insertion operator, and I did, but I have a problem with the syntax of printing something out. I have a method in my program called float Pay( float nDay) which calculates the total amount of money the person gets per day, multiplied by the number of days I choose.
For the overriden << operator, this is the statement I have...
stream << cn.ID<<" - "<< cn.getfirstname() << " " << cn.getlastname() << " (Total Pay: $"<< cn.Pay(float n) <<")"<<"\n";
Basically, it should print,
"ID - [First Initial] [Last Name] (Total Pay: $xxx.xx)
...My problem is, what syntax do I use to represent the pay. I would like it to be cn.Pay(float n), where n is a number that I input, but the only way the program works is if I put a specific number in the parentheses. How can I work around this?
(I thought about adding constructors to find the number of days, multiplying by the daily amount earned etc, but I'm not allowed to change the constructors. I hope this is not too vague, I refrained from posting the whole code because it's sort of long, and this looks like an easy fix. Thanks!